Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Custom Step Workflow with Ecma script

Manlosa
Level 1
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
Shubham_borole
Correct answer by
Community Advisor
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
Shubham_borole
Correct answer by
Community Advisor
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