Expand my Community achievements bar.

Adobe AEM 6.4.x workflows: graniteWorkItem is undefined when used in an OR split

Avatar

Level 8

I'm trying to run a script in an OR split and I keep on getting the error below. According to this page, "graniteWorkItem" is included in the list of "variables that are immediately available to process scripts, providing access to objects of the workflow Java API" (quoted from the link).

observations:

  • I tried "workItem" which I believe is the variable for CQ5? same error.
  • I removed the OR Split and then inserted a dynamic participant step. On the participant chooser, I selected Workflow Initiator Participant Chooser (Script). I then used the code below and ticked "email". I tried both "workItem" and "graniteWorkItem" variable names. I ran the workflow under my other acct and using both variable names, I got an email and no errors in error.log.

Any ideas what I'm doing wrong?

-----------------------------------

OR split script (with error. see below)

    function check() { 

        var workflowData = graniteWorkItem.getWorkflowData();

         return false; 

    }

dynamic participant script (no error with graniteWorkItem in the error.log)

    function getParticipant() {

        return graniteWorkItem.getWorkflow().getInitiator();

    }

error from error.log

    > tail -f error.log | grep -i "graniteWorkItem"

        var workflowData = graniteWorkItem.getWorkflowData();

    } : Failure running script /libs/workflow/scripts/dynamic.ecma: ReferenceError: "graniteWorkItem" is not defined. (NO_SCRIPT_NAME#2)

    org.apache.sling.api.scripting.ScriptEvaluationException: Failure running script /libs/workflow/scripts/dynamic.ecma: ReferenceError: "graniteWorkItem" is not defined. (NO_SCRIPT_NAME#2)

    Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "graniteWorkItem" is not defined. (NO_SCRIPT_NAME#2)

        var workflowData = graniteWorkItem.getWorkflowData();

    com.adobe.granite.workflow.WorkflowException: org.apache.sling.api.scripting.ScriptEvaluationException: Failure running script /libs/workflow/scripts/dynamic.ecma: ReferenceError: "graniteWorkItem" is not defined. (NO_SCRIPT_NAME#2)

    Caused by: org.apache.sling.api.scripting.ScriptEvaluationException: Failure running script /libs/workflow/scripts/dynamic.ecma: ReferenceError: "graniteWorkItem" is not defined. (NO_SCRIPT_NAME#2)

0 Replies