- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2023 09:05 AM
Hi Team,
We have a requirement to force run a workflow through fix script. I am new to this procedure. Could you please help me in script to run a workflow through sample script that can help me?
Sample script:
var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('Vendor Guest Acc Sync'), 'insert');
Thanks in advance,
Abhishek
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2023 06:58 PM
Hello,
Please see this reply for some assistance: https://www.servicenow.com/community/developer-forum/run-workflow-from-background-script/m-p/1904248
You need to associate the workflow to a record, thus you can use GlideRecord to either query an existing record and then use that object or you can use GlideRecord to insert a blank record and then associate that new blank record with the workflow.
Both methods are in the link I provided.
Please mark reply as Helpful/Accept Solution, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2023 06:58 PM
Hello,
Please see this reply for some assistance: https://www.servicenow.com/community/developer-forum/run-workflow-from-background-script/m-p/1904248
You need to associate the workflow to a record, thus you can use GlideRecord to either query an existing record and then use that object or you can use GlideRecord to insert a blank record and then associate that new blank record with the workflow.
Both methods are in the link I provided.
Please mark reply as Helpful/Accept Solution, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2023 07:46 PM
Can you share your complete fix script?
Also check point mentioned by Allen regarding GlideRecord
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader