I am getting started with workflows in ServiceNow. I can see that the trigger for at workflow is based on conditions. But can a workflow be triggered by some sort of user action, i.e. a UI Action/button or through a script?
Asked
Active
Viewed 8,110 times
1 Answers
4
There's a Workflow
object accessible server side that you can use to start a workflow that's documented here.
Here's an example from that wiki article:
// where current is a task record with a workflow context
var w = new Workflow();
var context = w.startFlow(id, current, current.operation(), vars);
current
: A GlideRecord that's beennext()
'ed to the record against which you're running the workflowid
: The sys_id of thewf_workflow
you want to run (NOTE: This is NOT the workflow version, thestartFlow
method handles determining which version is published and executes against it.vars
: The input variables that your target workflow accepts. This should be a JavaScript associative array e.g.:var vars = {variable1: "value1", variable2: "value2"};

Joey
- 2,901
- 21
- 22
-
That link appears to be dead now. Here's the link to the docs for Workflow as of Kingston: https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/Workflow/concept/c_Workflow_api.html#ariaid-title19 – Joey Mar 23 '18 at 14:28