How to trigger flow after record producer is submitted

mballinger
Mega Guru

Hello,

I have a record producer that once submitted, needs to trigger a flow designer flow. Is this possible? If so, how can I do that?

Thanks!

1 ACCEPTED SOLUTION

Jimmie Odelius
Giga Guru

Hi mballinger

Record producers in ServiceNow work by simply inserting a record into a table.
If you use catalog items you can specify a flow that should run from that requested item.

However if you still want to trigger a flow from a record producer, either match a flow condition with the created record or you can generate it from script. Full description here.

// Map inputs. For a flow with a record trigger, inputs are the record and table
	var inputs = {};
	inputs['current'] = current; // GlideRecord of table:  
	inputs['table_name'] = 'incident';

   // Execute the global flow called test_flow 
   sn_fd.FlowAPI.executeFlow('global.test_flow', inputs);

I've never used it in a record producer script. You might need to put it in a BR that triggers on insert but in that case setting a condition on the flow itself is probably easier.

View solution in original post

8 REPLIES 8

Martin Gr
Tera Contributor

Hi Shao
Thank for your sugestion, which I also thought was the way to go, but now the flow gets triggered everytime a record is created for that table (also when a user creates a bew record using a new record -button.

I would like very much to only trigger the flow when the record is created from a record producer,.. Do you know if that is possible.

best regards,

Martin

Shao
ServiceNow Employee
ServiceNow Employee

Hey Martin,

 

Is the table extending from task? If so, then you could probably add a condition that looks up if the record belongs to the sc_item_produced_record table before allowing the flow to proceed.

Martin Gr
Tera Contributor

Thanks Shao, that worked like a charm.. now the flow is only triggered when a work order is created from a catalog item (record producer), and I  can even check on the item it came from. Thanks.. much appreciated 🙂

 

 

 

Uncle Rob
Kilo Patron

There is a 100% reliable way to trigger flow from Record Producer without using code.
You simply use sc_item_produced_record table as a trigger.
It creates an entry at the same time the Task is created.  
It contains a link to the producer, and a link to the task.