need to trigger the workflow through scheduled script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 04:05 AM
can anyone make it correct way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 04:16 AM
The startFlow method of the Workflow API has four arguments, so try adding another
Also ensure the sys_id you are providing is that of a record, such as a Problem, RITM... which has a workflow associated to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 04:19 AM
Hi,
In StartFlow function you second argument needs to have the record this flow is for. Pass the right arguments and this will run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 04:35 AM
Please check the documentation and you will find many examples on how to use it.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 04:49 AM
@saikumarkak Below is the correct syntax
Workflow - startFlow(String workflowId, GlideRecord current, String operation, Array vars)
Starts a specified workflow.
workflowId | String | The sys_id of the workflow to start. This sys_id refers to table wf_workflow. |
current | GlideRecord | The record to use as current in this workflow. This is normally from the Table field of the workflow properties for this workflow. |
operation | String | The operation to perform on current. Possible values: insert, update, delete. |
vars | Array | Collection of variables to add to the workflow |
Example
////where current is a task record with a workflow context var w = new Workflow(); var context = w.startFlow(id, current, current.operation(), getVars());