Starting a workflow from Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2014 02:04 PM
Is there a way to call a workflow using script?I want the workflow to be only called from script and not by default when record is created for a table.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2014 09:05 PM
Aman,
What is the requirement? You can use these methods to manipulate scripts in a workflow Workflow Script - ServiceNow Wiki
or you could use scratchpad - Using the Workflow Scratchpad - ServiceNow Wiki
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 12:29 AM
use this script:
var w = new Workflow();
var context = w.startFlow(id, current, current.operation(), getVars());
In stead of current you can give glide record: gr (it must be glide record)
id: The sys_id of the workflow to start. This sys_id refers to table wf_workflow.
operation: insert or update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 12:32 AM
I am using the script to start the workflow but my actual issue is to prevent workflow from being called by default when record is created for a table. I guess i need to put in some conditions for the workflow initially and then only call that using script.
-Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 12:42 AM
I am assuming You are working on ritm table, eactivate start workflow business rule.
2nd. if other thaen RITM table, then in the condition of workflow
use a condition which is never be possible. Like created before 1999-12-12
3rd. If you are waiting for somthing to update, something to happen then only attach the workflow
then,
Please create custom field in table, and use the field in the condition
OR
after beging activity of workflow use a wait_for condition in workflow