AnsweredAssumed Answered

how to find documentLibrary using childByNamePath

Question asked by gerryr on Jan 14, 2014
Latest reply on Jan 14, 2014 by gerryr
I'm trying to populate the documentLibrary section of a new site using some javascript like this:

<javascript>sourceNode.copy(document.childByNamePath("documentLibrary"), true);</javascript>

where document is the new site.

This statement always errors though giving this error:
Destination Node is a mandatory parameter

but yet when I copy to the document root it works like this:

<javascript>sourceNode.copy(document, true);</javascript>

Why cannot it find the documentLibrary node?

More info:  I'm triggering this script from a rule on the Sites directory.  I'm wondering if there is a race condition where the site gets created under Sites but does not yet have it's documentLibrary node.  That would cause what I'm seeing if this can happen.

Yes something like this is happening because document.children is empty.
If I don't fire the rule the site gets created just fine and has a documentLibrary.
Why doesn't the site have all its children such as the documentLibrary when it first gets placed under Sites?