Trigger ServiceNow workflow from ui action?

Manish Shetty2
Giga Contributor

I am getting started with workflows in ServiceNow. I can see that the trigger for workflow is based on conditions. But can a workflow be triggered by some sort of user action? ie. i created "Form link" on incident form and i need to trigger a work flow when form link on the incident form is clicked.

Also i read in many articles that we have to pass input variables to the workflow, so need to know if we have to run workflow on clicking form link what would be the input variables to workflow and how do we pass it ?

Many thanks in advance.

 

Thank you,

Manish 

4 REPLIES 4

John Shores1
ServiceNow Employee
ServiceNow Employee

Yes, you can create a UI that triggers a workflow. You can pass the workflow variables by referring to the form fields with "current.field_name."  You can also create your own variables and assign values to them and pass them to the workflow.

Abhinay Erra
Giga Sage

Yes you can do all sorts of operations on the workflow using workflow api

Workflow

Manish Shetty2
Giga Contributor

Hello John & Abhinay,

Many thanks for your support.

it still dint work me.PFB piece of code which i added to ui action. 

var w = new Workflow();
var context = w.startFlow('3D73a371814f121300bf0aeb118110c715', current, current.operation(), getVars());

function getVars() {
var vars = {};
vars= current.cmdb_ci.getDisplayValue();

return vars;
}

 

 i am using vars as input to workflow .

 

Could you guys please help me here.

 

 

 

Thank You,

Manish

Devyani_6
Mega Guru

Hi Manish,

Plaese go through the below link

https://community.servicenow.com/community?id=community_question&sys_id=af22db21db101fc01dcaf3231f96191d

Mark if helpful

Warm Regards,

Devyani

find_real_file.png

|www.DxSherpa.com|