Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ahmed Heasat 10 posts 90 karma points
    Dec 03, 2019 @ 09:06
    Ahmed Heasat
    0

    NestedContent property in a member node always null - umbraco8

    Hi,

    I've added NestedContent property for a certain member, And I tried to return the NestedConent values as I usually do for nodes, I used the below code:

     member = Services.MemberService.GetByUsername(Membership.GetUser().UserName);          
     var NestedPackages = member.GetValue<IEnumerable<IPublishedElement>>("packages");
    

    And I got the NestedPackages value as null.

    Is there anyway to achieve it correctly ?

    Thanks,

  • iNETZO 57 posts 252 karma points
    Dec 03, 2019 @ 22:46
    iNETZO
    100

    Hi Ahmed,

    The member variable is of type IMember, which doesnt return iPublishedConent, it returns the raw value from the database which is in case of NestedContent a Json string. But you can convert this Json string to iPublishedContent by deserialize it via JsonConvert like this:

    var NestedPackages = JsonConvert.DeserializeObject<IEnumerable<IPublishedElement>>(member.GetValue<string>("packages"));
    

    I haven't tested the line above but i guess this could work.

    Best regards,

    iNETZO

  • Ahmed Heasat 10 posts 90 karma points
    Dec 04, 2019 @ 09:25
    Ahmed Heasat
    0

    Hi iNETZO,

    I have tried this way before, but i think we have better way like getting NestedContent in Razor.

    Thanks for help,

    Best regards,

    Ahmed

Please Sign in or register to post replies

Write your reply to:

Draft