Copied to clipboard

Flag this post as spam?

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


  • Matthew Berner 4 posts 104 karma points
    Sep 16, 2021 @ 13:55
    Matthew Berner
    0

    Ceating Nested Content programmically

    I have a Bulletin Board, people can add Notes through a form: One of Bulletin Boards Property is Notes and its element is a Board Note.

    I want to a Note to the specific Bulletin Board. My Issue when I add it does not show in the Bulletin Board Notes Property, it show us here:Content Image of Bad Placing

    They should be showing in Patient Corner in Notes: Correct Placement

    Can someone point me in the right direction, here is the code, I am missing something:

    var parentId = new Guid("bffd62cd-2591-4739-929e-eaba16e7f089");
    
            var NodeName = nModel.Title;
            IContent request = _contentservice.Create(NodeName, parentId, "bulletinBoard", -1);
            var Notebooks = new List<Dictionary<string, string>>();
            Notebooks.Add(new Dictionary<string, string>() {
            {"ncContentTypeAlias","boardNote"},
            {"title", NodeName},
            {"content", nModel.Note},
            {"className", nModel.ClassName },
            {"creator", null }}
                        );
    
            request.SetValue("notes", JsonConvert.SerializeObject(Notebooks));
            _contentservice.SaveAndPublish(request);
    

    Any help would be great. Matthew Berner

  • Matthew Berner 4 posts 104 karma points
    Sep 16, 2021 @ 15:03
    Matthew Berner
    100

    I figured it out on my own. I had to use my GUID and find its Id and use it. ` var parentId = new Guid("2bf7af33-5d21-44f8-860b-905afda4f2ef"); var Parent = _contentservice.GetById(parentId); var NodeName = nModel.Title; /IContent request = _contentservice.Create(NodeName, parentId, "bulletinBoard", 1);/

            var Notebooks = new List<Dictionary<string, string>>();
            Notebooks.Add(new Dictionary<string, string>() {
            {"ncContentTypeAlias","boardNote"},
            {"title", NodeName},
            {"content", nModel.Note},
            {"className", nModel.ClassName },
            {"creator", null }}
                        );
    
            Parent.SetValue("notes", JsonConvert.SerializeObject(Notebooks));
            _contentservice.SaveAndPublish(Parent);`
    

    Then it worked for me

Please Sign in or register to post replies

Write your reply to:

Draft