Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SubFlow on Server side Script

ServiceNowEmp
Giga Expert

Is it possible to call subflow/flow from Server side script?

2 ACCEPTED SOLUTIONS

Ravi Gaurav
Giga Sage
Giga Sage

Hi @ServiceNowEmp 

 

ServiceNow has provided "FlowAPI" class to call Flow/Subflow/Actions by using scriping. However, this can only be called from Server side scriping. So, when we want it to be called from Client side, we can use GlideAjax to invoke server side script which will trigger Flow/Subflow/Actions.


Let me know if you need sample script

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

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);

This script initializes an input object, sets the current record and table name, and then triggers a global Flow Designer flow named test_flow using the sn_fd.FlowAPI.executeFlow() method.

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

4 REPLIES 4

Ravi Gaurav
Giga Sage
Giga Sage

Hi @ServiceNowEmp 

 

ServiceNow has provided "FlowAPI" class to call Flow/Subflow/Actions by using scriping. However, this can only be called from Server side scriping. So, when we want it to be called from Client side, we can use GlideAjax to invoke server side script which will trigger Flow/Subflow/Actions.


Let me know if you need sample script

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Yes Please script will help !!

 

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);

This script initializes an input object, sets the current record and table name, and then triggers a global Flow Designer flow named test_flow using the sn_fd.FlowAPI.executeFlow() method.

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

ServiceNowEmp
Giga Expert

Thanks @Ravi Gaurav  that worked for me !!