siva_
Giga Guru

Hello All, 

WorkflowCoordinator object specifies which subflows to run and the input variables to pass to those subflows.

Just thought to share this information which i did in one of my recent implementations. I had a requirement where i have a MRVS(Multi row variable set) on a catalog item which has three fields and on the selection of two fields, there exists a combination in the backend table which specifies which subflow to run and the two fields will be the inputs to that workflow(Subflow)

Below is the script with comments : 

//Script from my parallel flow launcher activity...
javascript:  //should start with javascript:
var details = JSON.parse(current.variables.u_fill_in_your_request);//parsing my MRVS
coordinator = new WorkflowCoordinator( {workflow:'User Access to AD Group'} );//Initializing my workflow coordinator object with my workflow name to run***
for(var i = 0 ; i< details.length;i++){//traversing my MRVS to check and prepare the inputs to my about to trigger subflow 
var reqType = details[i].request_type_mv;
if(reqType == "Add Access"){
reqType = "Add";
}else{
reqType = "Remove";
}
var typeOfAcces = details[i].type_of_access;
var typeOfEnv = details[i].type_of_env;
var gr = new GlideRecord('u_user_access_provision_mapping');//Gliding data table to check which workflow to run based on the selected input combination on my MRVS
gr.addQuery('u_active',true);
gr.addQuery('u_item_name',current.cat_item);
gr.addQuery('u_type_of_access',typeOfAcces);
gr.addQuery('u_type_of_environment',typeOfEnv);
gr.query();
if(gr.next()){
if(gr.u_access_provisioned_by.toString() == "AD Group"){
coordinator.add({u_group:gr.u_ad_group.u_name,u_action:reqType,u_tkid:workflow.scratchpad.TKID });//passing the inputs to my coordintor object using add method of workflowCoordinator object
}
else{
coordinator.add({u_action:reqType,u_userid:workflow.scratchpad.TKID,u_role:gr.u_sailpoint_role},'Subflow - Sailpoint');//if the workflow needs to be called is different than what is used at the point of initialization (***) i need to pass the new workflow name as the second parameter here..
}
coordinator;//Must specify the variable holding the workflow coordinator object to return from the parallel workflow launcher activity .
}
}

This helped me to dynamically call different workflow based on what user filled in each row in MRVS in a single request.

Example Use Case: If we need to trigger multiple subflows based on each row in MRVS with different inputs to the subflow in a single request, I think this approach would be really helpful.

Let me know your comments , improvements and suggestions if any. 

Thanks, for your time. 

 

Mark this content as helpful if it really helps and been informative.... 

Comments
Tal3
Kilo Contributor
Is this option possible through the new flow designer?
Joshua Morriset
Giga Contributor

Yes, it is in Flow Designer, but a bit different.

 

In Flow Designer, you would use the Do the Following in Parallel flow logic, then from there you would add in the subflows.

Community Alums
Not applicable

Hi Siva,

Excellent article. I have a question, in coordinator.add function inside WorkflowCoordinator script include, it seems to accept two parameters, one is inputs and the other is workflow.
Is it required to send the workflow name in every coordinator.add function?

I wrote a script but it fails randomly. It says missing: after property id and after tracking this error, it goes to the add function in the script include. Sometimes it works but sometimes it gives error. I am not sure if I need to send the workflow name again. It is the same one which I am initializing at the start.

Thanks

siva_
Giga Guru

Hello Vishnu, 

Thanks for the feedback, I would appreciate if you can like the article. So coming to your question, 

If you have initialized it initially as in my example script and if you are using coordinator.add() function even multiple times, sending a single parameter is suffice , 

But if you want to send different parameters to a different subflow, then as mentioned in the example script, you need to call the different subflow name over there. 

Hope this helps.

Mark this response as helpful if that really helps.

 

Thanks,

Siva.

Version history
Last update:
‎08-10-2019 12:21 AM
Updated by: