ECMA Script for OR function workflow guide/reference/tutorial? | Community
Skip to main content
apd-support
February 8, 2019
Question

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

  • February 8, 2019
  • 3 replies
  • 1199 views

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?

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

3 replies

arunpatidar
Community Advisor
Community Advisor
February 8, 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.

Arun Patidar
apd-support
February 8, 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.

smacdonald2008
Level 10
February 8, 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 uses the MessageGatew…

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