Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Launch a subflow through a record producer

ronro2
Tera Contributor
Hi everyone!
 
I’m trying to figure out the best way to trigger a subflow from a Record Producer and could use some guidance.
 
Scenario:
  • I have a Record Producer based on a custom table (let’s call it table_x).
  • One of the variables is a Select Box called action.
  • One of the choices in that select box is add_restricted_access.
  • The user also selects an assignment group (reference to sys_user_group).
What I want to achieve:
When the user submits the Record Producer and the selected action is add_restricted_access, I want to automatically run a subflow that:
  1. Finds all records in table_x that match the chosen assignment_group.
  2. Updates the field u_restricted_read_access to false for all those matching records.

So basically we want to restrict reading access records on table table_xfor the assignment group chosen through the record producer. 

So my question is..
Is it possible to initiate a subflow directly from a Record Producer based on the selected variables?
And if so, what is the recommended approach or best practice for doing this?
Any advice, examples, or pointers would be greatly appreciated!
4 REPLIES 4

yashkamde
Kilo Sage

Hello @ronro2 ,

 

As per my understanding, Yes you can initiate a subflow but,

don’t try to invoke the subflow directly from the Record Producer script. Instead, let the record creation event trigger a Flow, and let that Flow call the subflow. This separation of concerns is the cleanest, most scalable approach.

Refer this :

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2657568 

If my response helped mark as helpful and accept the solution.

Ankur Bawiskar
Tera Patron

@ronro2 

you can trigger flow based on Record producer submission

In process engine you can associate the published flow

OR

You can use after insert BR on that target table and then call subflow from it and pass that record sysId as input and then handle it

Flows and Subflows 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron

@ronro2 

you can trigger flow when record producer is submitted

🌊 YES, You CAN Launch a Flow from a Record Producer 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Animesh Das2
Mega Sage

Hi @ronro2 ,

 

Best approach is to create a flow with triggering condition as 'created or updated' on table_x based on required condition and that flow will have subflow inside.

Otherwise, if want to trigger the subflow directly, you can try using FlowAPI, triggered from a server side script(BR). Please have a look at the blog post for the relevant FlowAPIs.

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das