Custom Step Workflow with Ecma script | Community
Skip to main content
July 19, 2021
Solved

Custom Step Workflow with Ecma script

  • July 19, 2021
  • 1 reply
  • 2325 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Shubham_borole

Hi,

Please follow https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-customizing-extending.html?lang=en#ecma-scripts

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-user-or-group-for-aem-workflow.html?lang=en two scrips under " /apps/fd/dashboard/scripts/" is described 

More links -https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-program-interaction.html?lang=en#obtaining-workflow-objects-in-ecma-scripts

https://github.com/AdobeDocs/experience-manager-64.en/blob/master/help/sites-developing/workflows-program-interaction.md#obtaining-workflow-objects-in-ecma-scripts 


1 reply

Shubham_borole
Community Advisor
Shubham_boroleCommunity AdvisorAccepted solution
Community Advisor
July 19, 2021

Hi,

Please follow https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-customizing-extending.html?lang=en#ecma-scripts

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-user-or-group-for-aem-workflow.html?lang=en two scrips under " /apps/fd/dashboard/scripts/" is described 

More links -https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-program-interaction.html?lang=en#obtaining-workflow-objects-in-ecma-scripts

https://github.com/AdobeDocs/experience-manager-64.en/blob/master/help/sites-developing/workflows-program-interaction.md#obtaining-workflow-objects-in-ecma-scripts