Copied to clipboard

Flag this post as spam?

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


  • Mahender Singh 39 posts 170 karma points
    Jul 11, 2022 @ 06:48
    Mahender Singh
    0

    How to append already Published content to MulltiNode Content Picker in V9

    Hi Team,

    I have configured Parent child relationship between Datatypes in umbraco using Multinode Content picker.

    Now I want to append more relationship in backend. Can you please help to guide me how i can achive this.

    using (var cref = _umbracoContextFactory.EnsureUmbracoContext())
                    {
                        var categoryContent = _contentService.GetById(new Guid("8e138bc7-d38c-4508-a5fb-ed48b701f6c0"));
                         IPublishedContent publishedContent = cref.UmbracoContext.Content.GetById(new Guid("8e138bc7-d38c-4508-a5fb-ed48b701f6c0"));
    
                        var storeContent = _contentService.GetById(new Guid("a5dd1ea8-01ae-44c0-9cd8-42fe3929f890"));
                        var categoryProperty = storeContent.Properties.Where(x => x.Alias.ToLower() == "categories").FirstOrDefault();
                        var cateValues=categoryProperty?.GetValue("en-us");
                        storeContent.SetValue("categories", categoryContent.Key,"en-us");
    
                        _contentService.SaveAndPublish(storeContent);
                    }
    

    I am using ContentService but not able to add content.

    Category relationship

  • Andrey Karandashov 23 posts 215 karma points c-trib
    Jul 11, 2022 @ 08:06
    Andrey Karandashov
    100

    Hi,

    storeContent.SetValue("categories", categoryContent.Key,"en-us");
    

    You need to convert your key (Guid) into Udi: https://our.umbraco.com/documentation/reference/querying/Udi

  • Mahender Singh 39 posts 170 karma points
    Jul 12, 2022 @ 06:04
    Mahender Singh
    0

    Thanks Andrey for this help

Please Sign in or register to post replies

Write your reply to:

Draft