Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Understanding how OR Split in workflow works

anands82757572
Level 2
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
Arun_Patidar
Correct answer by
Community Advisor
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

View solution in original post

5 Replies
Arun_Patidar
Correct answer by
Community Advisor
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

View solution in original post

evancooperman-s
Level 2
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, @Arun_Patidar, 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.

evancooperman-s
Level 2
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.

antond26624417
Level 2
Level 2

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