Starting a workflow from Script

agulati
Kilo Expert

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

4 REPLIES 4

JamesEcoStratus
Mega Guru

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


Chandan23
Tera Expert

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



agulati
Kilo Expert

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


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