Copied to clipboard

Flag this post as spam?

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


  • Shola 65 posts 273 karma points
    Jun 15, 2018 @ 17:24
    Shola
    1

    How to call Member.SetValue of ContentPicker2 field (Id vs Udi vs Guid)

    Hello all,

    Using Umbraco 7.7.13

    I'm having trouble pinning down the recommended way to use the MemberService to save a member's ContentPicker2 field value.

    Here's how I used to do it with Ids according to the documentation (myMember is an IMember, and food is an IPublishedContent):

    myMember.SetValue("favoriteFood", food.Id);
    ApplicationContext.Current.Services.MemberService.Save(myMember);
    

    But I've read that won't work if favoriteFood is a ContentPicker2, and I should use a Udi. What is the recommended fool-proof way of doing the above via Udi from the IPublishedContent food (without hitting the database to find food's Udi)?

    I've read some things about unwrapping the IPublishedContent--but I don't think it provides the full solution for the above.

    Thank you!

  • Shola 65 posts 273 karma points
    Jun 15, 2018 @ 18:44
    Shola
    0

    I believe this looks very promising, but I've also read that IPublishedContent.GetKey() can be an empty Guid sometimes:

    https://blogit.create.pt/marionunes/2017/11/05/working-with-umbraco-7-6-new-pickers/

    Does anyone know why/how IPublishedContent.GetKey() can sometimes be empty?

Please Sign in or register to post replies

Write your reply to:

Draft