Copied to clipboard

Flag this post as spam?

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


  • Davit 7 posts 88 karma points
    Apr 22, 2020 @ 12:24
    Davit
    0

    How can I add an item to nested-content (IEnumerable<IPublishedElement>>("usps")) programmatically?

    I have usps nested-content property on-page and I want to add a new item to usps list from backend

    The item property name is usp

    Thanks in advance.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 22, 2020 @ 12:42
    Alex Skrypnyk
    101

    Hi Davit,

    Something like:

    var list = new List<Dictionary<string, string>>();
    
    Guid guid1 = Guid.NewGuid();
    
    liste.Add(new Dictionary<string, string>(){
        {"key","@guid1"},
        {"name","Some name"},
        {"ncContentTypeAlias","usp"},
        {"Property in NestedContent","Some Text"},
    });
    
    node.SetValue("usps", JsonConvert.SerializeObject(list));
    

    Thanks,

    Alex

  • Rihab 104 posts 387 karma points
    Aug 27, 2020 @ 11:29
    Rihab
    0

    Hi Alex

    I did it your way and it works fine when adding and in the backoffice the values are added, but when I retrieve the value to show it on my website I got this error enter image description here can you help me to solve this error?

  • Kiran 17 posts 108 karma points
    Feb 02, 2021 @ 12:50
    Kiran
    1

    Hi Alex, I am new to Umbraco. How do I get node in your example. Currently i am using umbraco 8.8 . Can you please suggest me. .

  • Davit 7 posts 88 karma points
    Apr 22, 2020 @ 13:14
    Davit
    1

    Alex thank you very much it works perfectly.

    Thanks David

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies