Quantcast
Channel: Adobe Community : Unanswered Discussions - Digital Marketing Suite
Viewing all articles
Browse latest Browse all 937

Custom Workflow - Creating Nodes with ECMA script

$
0
0

Hey y'all,

 

I'm working in CQ5.5 on a custom workflow in an ecma file to do the following:

Given the creation of a page of template type A, automatically create a page of template type B and populate some of the content from page A into page B. I have no problem creating the page but when I go to insert content, it is not giving me a node called test under jcr:content, like I would expect. Anyone have any ideas?

 

     //this code works

    var resolver = sling.getService(Packages.org.apache.sling.jcr.resource.JcrResourceRe solverFactory).getResourceResolver(session);

    var pageManager = resolver.adaptTo(Packages.com.day.cq.wcm.api.PageManager);

     // get containing page in /content/usergenerated

    var containingPage = pageManager.getContainingPage(path);

    var newPage = pageManager.create(path, containingPage.getName(), template, containingPage.getTitle());

 

     // below code doesn't work

    var jcrUtil = sling.getService(Packages.org.apache.sling.jcr.resource.JcrResourceUt il);

    jcrUtil.createPath(newPage.getPath() + "/jcr:content/test", null, null, session, true);


Viewing all articles
Browse latest Browse all 937

Trending Articles