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.
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..
}
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..
}