How to start a workflow from script include using UI action?

animeshmishra02
Kilo Contributor

Hi All

We have a requirement to trigger workflow using UI action. We are able to call script include from UI action but not able to call workflow.

Thanks in advance,

Regards,

Animesh

13 REPLIES 13

Chuck Tomasi
Tera Patron

Hi Animesh,



Can I ask why you want to start the workflow from a UI action? I'm always curious on the use case for this. My personal preference is to let the workflow start itself based on a condition in the workflow properties (State | is | Approval - for example.) Let the UI action set the state to approval and let the workflow start itself.


hey ctomasi what do you think of this reasoning for a UI action that starts a workflow...:



UI Action that can be selected and force an incident into an approval workflow that changes specific incident fields based on what happens in the workflow. Example: UI Action selected and the incident is passed into the workflow. Workflow immediately changes assigned user to Joe and an approval request is sent to Joe. If approved it is assigned back to the user who hit the ui action. if rejected, a reject reason is mandatory and entered into the work notes of the incident and assigned back to the user.  






i need to do this but.. i think the better way to do is the way you mentioned above... and how can i accomplish the ui action to state approval? condition in the ui action? what would that condition be?


Hi Rey,



Based on your requirements I would do this:



  1. Create a field on incident (e.g. u_assigned_to_approval, type=true/false, default=false)
  2. Create a workflow with a condition to only start when u_assigned_to_approval is true
  3. Use your UI action to set assigned_to as "Joe" and u_assigned_to_approval to true - that will trigger the WF to start
  4. Ensure the WF does a Set Value activity near the end to set u_assigned_to_approval back to false.


Much simpler - and easy to maintain.



Reference:


Workflow Concepts - ServiceNow Wiki


Creating a Workflow - ServiceNow Wiki


Using Workflow Activities - ServiceNow Wiki