Expand my Community achievements bar.

Unable to access workItem in OR split of ECMA script

Avatar

Former Community Member

Hi,

    I just want to set rule to OR split branch. I tried accessing work Item in my script,but I am getting Reference Error for WorkItem.

    For my requirement I just want to take a decision based on previous participant step comments. I used below code to get history from work Item.

var history = workflowSession.getHistory(workItem.getWorkflow());

    Is it correct way to achieve this?.    

    Error: Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "workItem" is not defined.

    Please guide me how to proceed with this

 

    Thanks!

 

 

     Kirithi

3 Replies

Avatar

Employee Advisor

What version of AEM you are working on ? From 5.6.1, the variable for workItem is called as "graniteWorkItem". Check the following section "Implementing a Process Step with an ECMA Script" in the documentation link [1]. 

 

[1] https://docs.adobe.com/docs/en/cq/5-6-1/workflows/wf-extending.html

Avatar

Former Community Member

Hi,

    I am using CQ-6.0.0.I am facing same error for graniteWorkItem. I am using below code in ECMA script for testing

var workflowData = graniteWorkItem.getWorkflowData(); log.info("workflowData:::"+workflowData); Failure running script /etc/workflow/scripts/validateMetaData.ecma: ReferenceError: "graniteWorkItem" is not defined.           (/etc/workflow/scripts/validateMetaData.ecma#1)

 

  Thanks!

  Kirithi

 

Avatar

Level 3

OR Step only has these vars defined workflowData, jcrSession, workflowSession So you need to do things along this way...

function check(/*workflowData, jcrSession, workflowSession*/) {

//     var path = workflowData.getPayload().toString();
//     var node = workflowSession.getSession().getItem(path);
//     return !(node.hasProperty("status") && node.getProperty("jcr:content/acPublishState").getString().equals("prepared"));

}

 

http://blogs.adobe.com/dmcmahon/2013/03/26/cq5-failure-running-script-etcworkflowscriptscaworkitem-e...