Copied to clipboard

Flag this post as spam?

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


  • Ben 91 posts 111 karma points
    Jan 11, 2012 @ 13:49
    Ben
    0

    Node seems not to have children

    Hi, 

    I create new documents via the umbraco 4.7 API:

    Document.MakeNew(name, DocumentType.GetByAlias("News"), User.GetUser(0), 1200)

    You can see I set their parent nodeId to 1200. The problems occures when I try to find the children of the node with id 1200:

    new Node(1200).Children / new Node(1200).ChildrenAsTable() / new Node(1200).ChildrenAsList

    all of the above methods return no children. Can you assume why?

    Thanks from advance

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 11, 2012 @ 14:01
    Tom Fulton
    1

    Hi Ben,

    It looks like in your first example you are using the Document API and the NodeFactory API in the second.  NodeFactory only works with published data.  So I would assume the children aren't published yet, that should be the only reason you wouldn't see them.

    So you can either try using the Document API on your second call, or publish the node after you create it.  See this page for more info on the differences and this page for info on publishing a document afer you create it.

    Hope this helps,
    Tom

  • Ben 91 posts 111 karma points
    Jan 11, 2012 @ 14:27
    Ben
    0

    Hi,

    I did use the Document.Publish method but I didn't know about the umbraco.library.UpdateDocumentCache. 

    Now I use it and it works fine. THANKS!

Please Sign in or register to post replies

Write your reply to:

Draft