rasmusjp / umbraco-multi-url-picker

Multi Url Picker for Umbraco 7
MIT License
31 stars 29 forks source link

"Unable to cast" error with Umbraco 7.4.2 and Archetype #43

Open dreadpiratebrown opened 8 years ago

dreadpiratebrown commented 8 years ago

Trying to use the Multi Url Picker inside an Archetype data type. Here is my Razor code to get the URL:

var multiUrlPicker = fieldset.GetValue<MultiUrls>("buttonURL");
if (multiUrlPicker.Any())
{
    foreach (var item in multiUrlPicker)
    {
        <p><a href="@item.Url" class="btn btn-primary btn-lg">@fieldset.GetValue("buttonText")</a></p>
    }
}

When I view the page, I get this system error:

Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JArray'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JArray'.

Source Error:

Line 79: @if (fieldset.HasValue("buttonURL")) Line 80: { Line 81: var multiUrlPicker = fieldset.GetValue("buttonURL"); Line 82: if (multiUrlPicker.Any()) Line 83: {

Is this something I'm doing wrong, or is it incompatible with 7.4.x?