Pass flow variables of flow designer flow from Business Rule

deepak50
Tera Contributor

Hi Team,
I am creating a flow designer flow which uses flow variables. we can set flow variables and use those in flow designer script.
eg
var flowvar=fd_data.flow_var.flowvar1;

But how can we pass flow variable from outside flow designer.

For eg.
we can call a flow designer flow from business rule using code as below

inputs['current'] = ; // GlideRecord of table:  
inputs['changed_fields'] = ; // Array.Object
inputs['table_name'] = 'sn_customerservice_case';
sn_fd.FlowAPI.getRunner().flow('flow_name').inForeground().withInputs(inputs).run();

can we also set flow variables from Business rule while calling this flow, I tried setting them in inputs[] as

inputs['flowvar1']= 10;

but it did not work.

Please let me know how can we pass flow variable from outside flow designer.

thanks
-Deepak

1 ACCEPTED SOLUTION

Geoff_T
Mega Sage

Hi,

I think the only way to do this with a regular flow would be to capture the flow variable values as part of the 'current' record; then extract them from within the flow. This likely will not work for you as there probably isn't somewhere on the current record to store the flow variable values you want.

 

Alternatively, if the process will only be initiated from your business rule, create a sub flow instead. This way you can can define your flow variable inputs and pass them as required like below:

 

find_real_file.png

 

(function() {
	
	try {
		var inputs = {};
		inputs['flow_variable_one'] = ; // defined Flow Variable one
		inputs['flow_variable_two'] = ; // defined Flow Variable two

		// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
		// sn_fd.FlowAPI.getRunner().subflow('flow_name').inBackground().withInputs(inputs).run();
				
		// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
		var result = sn_fd.FlowAPI.getRunner().subflow('flow_name').inForeground().withInputs(inputs).run();
		var outputs = result.getOutputs();

		// Current subflow has no outputs defined.		
	} catch (ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
	
})();

 

 

Geoff

View solution in original post

3 REPLIES 3

Kieran Anson
Kilo Patron

Hi Deepak,

Not sure I fully understand, are you wanting to pass the output of one flow into the input of another?

 

Geoff_T
Mega Sage

Hi,

I think the only way to do this with a regular flow would be to capture the flow variable values as part of the 'current' record; then extract them from within the flow. This likely will not work for you as there probably isn't somewhere on the current record to store the flow variable values you want.

 

Alternatively, if the process will only be initiated from your business rule, create a sub flow instead. This way you can can define your flow variable inputs and pass them as required like below:

 

find_real_file.png

 

(function() {
	
	try {
		var inputs = {};
		inputs['flow_variable_one'] = ; // defined Flow Variable one
		inputs['flow_variable_two'] = ; // defined Flow Variable two

		// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
		// sn_fd.FlowAPI.getRunner().subflow('flow_name').inBackground().withInputs(inputs).run();
				
		// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
		var result = sn_fd.FlowAPI.getRunner().subflow('flow_name').inForeground().withInputs(inputs).run();
		var outputs = result.getOutputs();

		// Current subflow has no outputs defined.		
	} catch (ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
	
})();

 

 

Geoff

deepak50
Tera Contributor

Thanks for your reply. this worked.