Copy a Flow using API or Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 07:34 AM
Dear All,
Is there any way to copy a Flow using the script/API NOT from the content menu.
Any help is appreciated.
Regards,
Yusuf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 01:24 AM - edited 04-15-2025 01:25 AM
Hi! This took me a couple hours to figure out and do some testing (Should be okay considering I started learning ServiceNow few weeks back 😁)
- So I checked API reference and there was no out of the box API or Script action that could copy a flow, thoroughly.
- However, I realized that since everything you see on ServiceNow is stored in tables, and those tables can be accessed and manipulated (to some extent), I found that Flows are stored in sys_hub_flow, and some fields are inherited from sys_hub_flow_base. You can open these tables directly by entering sys_hub_flow.list or sys_hub_flow_base.list in the Application Navigator.
- Next I created a new UI Action on the sys_hub_flow.list to create a new Flow and copy the selected record.
- I was successful, but not fully. It copied the Flow successfully, and some of its fields, but it did not copy the Triggers, Conditions, Actions, Variables, etc.
- You could use this method, however, you would then have to create not just sys_hub_flow record, but also new records of its referencing tables like Variables, Triggers, Conditions and Actions. It would come out to be quite a complicated script.
So all in all, it's possible, just need to put some effort into the UI Action script.
I've attached two screenshots:
- UI Action (script) that I created
- Referencing tables of sys_hub_flow
Good luck!
================================================