Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Understanding how OR Split in workflow works

Avatar

Level 2

I am having some troubles understanding how the OR split works.

I have a workflow model that is supposed to do the following:

1. Check if page is valid

2. If yes

          2a. Deactive page

          2b. Move and Archive page, more like a soft delete of content

          2c. Notification email

3. If No

          3a. Notification email

In Step 1, I set the following key/value pair:

item.getWorkflowData().getMetaDataMap().put("IsValid", String.valueOf(isValidContent));

In the OR condition, I have this in the ecma script for Batch 1:

function check() {

var isValidContent = graniteWorkItem.getWorkflowData().getMetaDataMap().get("IsValid");

log.info("isValidContent = "+isValidContent);

if (isValidContent === "true"){

return true;

}else{

return false;

}

}

What does this mean? Branch 1 will be triggered when check() returns true and Branch 2 for all false? What should the check() condition in Branch 2 return? I am a bit lost and need some help on this to understand how the split works.

Thanks,

Anand

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Only a single branch can run, if it return true. If no branch returns true then it will go to the default route if one is set, otherwise the OR Split will error.

for Branch2 you need to write like below or set one of them as Default route

if (isValidContent !== "true"){

return true;

}

This should work!

Thanks

Arun



Arun Patidar

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Only a single branch can run, if it return true. If no branch returns true then it will go to the default route if one is set, otherwise the OR Split will error.

for Branch2 you need to write like below or set one of them as Default route

if (isValidContent !== "true"){

return true;

}

This should work!

Thanks

Arun



Arun Patidar

Avatar

Level 2

Just an FYI, please read my comment as this isn't entirely true. If no branch returns true, then it will error. It will not go to the default route in that case. It will only go to the default route if both routes return true.  That being said, @arunpatidar, your logic is correct in that if you force the second branch to return true when the first returns false, then it will always take that route by default if it finds the first branch is not viable.

Avatar

Level 2

This is what I thought too, but even when I set default route for 1 branch, and both branches return false, it throws an exception that it doesn't know which route to take.   I believe the default route will only be used if both branches return true, not if they both return false.  A branch returning false means it's not a viable branch, so if both branches return false then AEM doesn't think either branch is viable.

Avatar

Level 2

@evancooperman-smith  I think your answer is more like true. This is what exactly officially documented.
Workflow Step Reference

Avatar

Level 1

Can you please tell where can i find the logs of this script? like you have used log.info here. where ti find the logs for this?