Expand my Community achievements bar.

SOLVED

Custom Step Workflow with Ecma script

Avatar

Level 1

Hi there, 

    Newbie here. Does anyone know of a good working example of a workflow step written in Ecma Script? Also, looking for some step-by-step or best practices in building workflow step using Ecma Script.

 

Thanks,

-Leo

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Please follow https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-wor...

You can see example scripts under /libs/workflow/scripts/ but as mentioned in the documentation do not change anything there. You will have to create a structure under /apps  and add the file there.

 

Eg

var workflowData = graniteWorkItem.getWorkflowData();
if (workflowData.getPayloadType() == "JCR_PATH") {
    var path = workflowData.getPayload().toString();
    var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
    var node = jcrsession.getNode(path);
    //Custom code - some action on the node..
}

Here - https://experienceleague.adobe.com/docs/experience-manager-64/forms/workflows/dynamically-select-a-u... two scrips under " /apps/fd/dashboard/scripts/" is described 

More links -https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-wor...

https://github.com/AdobeDocs/experience-manager-64.en/blob/master/help/sites-developing/workflows-pr... 


View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi,

Please follow https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-wor...

You can see example scripts under /libs/workflow/scripts/ but as mentioned in the documentation do not change anything there. You will have to create a structure under /apps  and add the file there.

 

Eg

var workflowData = graniteWorkItem.getWorkflowData();
if (workflowData.getPayloadType() == "JCR_PATH") {
    var path = workflowData.getPayload().toString();
    var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
    var node = jcrsession.getNode(path);
    //Custom code - some action on the node..
}

Here - https://experienceleague.adobe.com/docs/experience-manager-64/forms/workflows/dynamically-select-a-u... two scrips under " /apps/fd/dashboard/scripts/" is described 

More links -https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-wor...

https://github.com/AdobeDocs/experience-manager-64.en/blob/master/help/sites-developing/workflows-pr...