ECMA Script for OR function workflow guide/reference/tutorial?

apd-support

07-02-2019

Hi guys,

I want to add workflow to check if the page is active or not? I have try with following code, but couldn't get success;

function check() {

    if (workflowData.getPayloadType() == "JCR_PATH") {

        var path = workflowData.getPayload().toString();

        var node = workflowSession.getSession().getItem(path);

        if(node.hasProperty("cq:lastReplicationAction") && node.getProperty("cq:lastReplicationAction").getString() == "Activate") {

            return true;

        } else {

            return false;

        }

    } else {

        // should not happen

        return false;

    }

}

Beside how I can see log for ECMA script after I added line log.error or log.info?

Is there any website or tutorial I can refer to create ECMA script for OR function workflow?

Accepted Solutions (0)

Answers (3)

Answers (3)

smacdonald2008

08-02-2019

All of our AEM HELPX Artilces that show how to customize a workflow use a custom AEM Step built with the Java Workflow Strongly-typed APIs. For example:

Adobe Experience Manager Help | Creating an Adobe Experience Manager 6.4 custom workflow step that u...

The above article shows you to create a custom workflow step that uses the Workflow Java API.

For scripts - we cover that in the AEM standard product docs:

Extending Workflow Functionality

apd-support

07-02-2019

Hi Arun,

I have check for both log, but it not show any.

I'm expecting the 1st branch to return true from above ECMA script but I'm guess it's not, since the step on 1st branch is not trigger. I'm looking on how to test or get node value for property  "cq:lastReplicationAction" as to return true value.

Arun_Patidar

MVP

07-02-2019

Hi,

You can check logs either in error.log or stdout.log

for OR steps, the branch will be executed when there is true return by script. It doesn't work like if else.

You need to return true for branch if you want to execute in branch and if there is a possibility where none of the branch return true then you should have default route set.