Copied to clipboard

Flag this post as spam?

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


  • BJ Patel 84 posts 210 karma points
    Jul 13, 2021 @ 03:59
    BJ Patel
    1

    How to Create node on Root In umbraco 8 From controller

    Hi,

    I use the following code to create a node from the Controller: which create a node on the base of the Parent node [ParentGuid]:

    using Umbraco.Web.Mvc;
    var contentService = Services.ContentService; 
    var newNode = contentService.Create("node Name", [ParentGuid], "docTypeName");
        ....
         ....                 
    
        contentService.Save(newNode); 
    

    Now I need to create a node on the root level, so need guidance on it. How to create a node at the root level?

    Thanks

    BJ

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Jul 13, 2021 @ 06:15
    Marc Goodson
    0

    Hi BJ

    Historically, if you set the value of the parent to -1

    That means the 'root' of the tree you are creating the item in.

    I say historically, as I haven't done it for a while, and I'm not sure things changed when udi's were introduced, but I reckon it's 'still the way'.

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft