3 Replies Latest reply on Mar 25, 2013 10:36 AM by rush_pawan

    Custom Workflow - Creating Nodes with ECMA script

    mdp3

      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.JcrResourceResolverFactory).getRe sourceResolver(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.JcrResourceUtil);

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