How to trigger ServiceNow workflow from ui action?

∥☆過路亽.° 提交于 2019-12-24 02:18:06

问题


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?


回答1:


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 been next()'ed to the record against which you're running the workflow
  • id: The sys_id of the wf_workflow you want to run (NOTE: This is NOT the workflow version, the startFlow 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"};


来源:https://stackoverflow.com/questions/33933776/how-to-trigger-servicenow-workflow-from-ui-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!