Workflow Conditions based on list collector variable

Adarsh T
Tera Contributor

Hi,

I have a catalog item with one of the variables as a list collector. I have two options which are "Add / Modify Application Access" and "Get iManage Add-in". If I choose "Add / Modify Application Access" option then it should trigger an approval and catalog task etc, In the same way, if I am selecting Get iManage Add-in then it should trigger a different catalog task and the flow goes on. I have handled both the scenarios in my workflow with the switch.

The challenge I am facing is if I am selecting both the options then it should trigger both the flows. I handled that also inside switch as a condition but in spite of just triggering the both condition alone, it is triggering the other two conditions along with both. Hence it is creating a mess triggering multiple tasks and approvals. How to handle this if I am selecting both the values and it should trigger the flow accordingly?

Below are my conditions added inside the Branch activity:

Add / Modify Application Access- current.variables.request.toString().indexOf('f39a272a1b4fc1900dd7fdd91d4bcbd9') != -1

Get iManage Add-in- current.variables.request.toString().indexOf('a7aa272a1b4fc1900dd7fdd91d4bcb93') != -1

Both- (current.variables.request.toString().indexOf('f39a272a1b4fc1900dd7fdd91d4bcbd9') != -1) && (current.variables.request.toString().indexOf('a7aa272a1b4fc1900dd7fdd91d4bcb93') != -1)

 

Attaching the screenshot of the workflow.

1 ACCEPTED SOLUTION

You don't need to build logic by scripts:

Use if condition workflow activity and if script:

answer = ifScript();

function ifScript(){

var req = current.variables.request.toString();

if(req.indexOf('a7aa272a1b4fc1900dd7fdd91d4bcb93') != -1)

    return 'yes';

else

    return 'no';

}

Best Regards
Aman Kumar

View solution in original post

8 REPLIES 8

Adarsh T
Tera Contributor

@Ankur Bawiskar -- any thoughts?

Aman Kumar S
Kilo Patron

Instead of this, why don't your go with nested if workflow activity

First if will check for both, 

(Access && Get iManage Add-in) -> if yes, do your catalog task and approval

if No,

Check Access -> if yes, do your catalog task and approval

if No,

Get iManage Add-in ->if yes, do your catalog task and approval

 

Hope you are able to visualize

Let me know, if this clear things up for you

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Can you help me with the code, I once tried with it and I failed after that only I started using a branch.

If you can help me with the code, it would be great. Below are the details:

List collector variable name- request

Values-    B

Text Value sys_id
Add / Modify Application Access  add f39a272a1b4fc1900dd7fdd91d4bcbd9
Get iManage Add-in get a7aa272a1b4fc1900dd7fdd91d4bcb93

You don't need to build logic by scripts:

Use if condition workflow activity and if script:

answer = ifScript();

function ifScript(){

var req = current.variables.request.toString();

if(req.indexOf('a7aa272a1b4fc1900dd7fdd91d4bcb93') != -1)

    return 'yes';

else

    return 'no';

}

Best Regards
Aman Kumar