How to start a workflow from script include using UI action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 06:28 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 06:34 AM
Use this line of code:
startFlow(workflowId, current, operation, vars)
Workflow Script - ServiceNow Wiki
Starting a workflow from Script
How to trigger a workflow from a business rule?
See this links it will help you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 06:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2017 01:30 PM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 05:32 AM
Hi Rey,
Based on your requirements I would do this:
- Create a field on incident (e.g. u_assigned_to_approval, type=true/false, default=false)
- Create a workflow with a condition to only start when u_assigned_to_approval is true
- Use your UI action to set assigned_to as "Joe" and u_assigned_to_approval to true - that will trigger the WF to start
- 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