Implementing multiple subflows in a LE activity


OOB we support flow activity only for switch primary jobs, however, if you would like to implement it to multiple flows, please make the following changes.

Suppose you would like to have multiple subflow (say subflow A and subflow b) in the lifecycle event you might want to change the _generateFlowActivity method to something like this below 

_generateFlowActivity: function(parentCase, activity) {
var errorMessage = 'Unable to create Flow Activity ' + activity.title + '\': Flow not specified';
if (!gs.nil(activity.flow)) {
var inputs = {};
var flow = activity.flow.internal_name;
var scope = String(activity.flow.sys_scope.scope);

if(flow == <flowA.internal_name>){

inputs['param1'] = <populate param 1 for the flow A>
/*likewise populate all the params */

}

if(flow == <flowB.internal_name>){

inputs['param1'] = <populate param 1 for the flow B>
/*likewise populate all the params */

}

var context = sn_fd.FlowAPI.startSubflow(scope + '.' + flow, inputs);
if (context) {
var grFlowExecution = new GlideRecord('sys_flow_context');
if(grFlowExecution.get(context))
return grFlowExecution;
}
} else {
gs.error(errorMessage);
throw new sn_hr_le.sn_hr_LE_Error(errorMessage, {});
}
},


The idea in the above code is to populate the inputs object with the appropriate input value required for the desired subflow.  

Note: If there is an in-family upgrade in New York/Orlando, please add a reference qualifier in the flow field in the sn_hr_le_activity table to have the flow_type as subflows.


Q: How to set up reference qualifiers? 

If you have access to the code base change the sn_hr_le_activity table to the following:

<element label="Flow" name="flow" type="reference" reference="sys_hub_flow" reference_qual="javascript:'active=true^status=published^type=subflow'" />

We can add this through platform UI as well. 

  1. Go to System definitions > table > go to activity table(sn_hr_le_activity)
  2. Select the column named Flow
  3. Modify the reference qualifier to javascript:'active=true^status=published^type=subflow'
  4. Save/Update the record