Wait for condition based on script tasks created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 08:18 AM
Hello, I have an interesting question for me I've created a script that creates tasks based on how many roles are in a Group, right now I'm using the "wait for condition." that comes in the workflow editor, but i approve a task and its getting stuck in the wf.
So is there a script i can run in a workflow that "waits" for all approvers in that certain stage to approve, how would that look like? or any tips or suggestions are welcomed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 08:33 AM
Hi @HenryD ,
You can use approval coordinator in Wokflow.
The Approval Coordinator activity creates an approval whose outcome depends on the outcome of one or more child activities, including one or more Approval - User, Approval - Group, and/or Manual Approval activities.
To create an Approval Coordinator activity, first drag the activity onto the workflow canvas, causing the activity form to display. On the activity form, fill in the appropriate fields, then click Submit.
After you click Submit, the activity appears on the workflow canvas. From there, specify the child activities by clicking the links that appear on the body of the activity.
When the Approval Coordinator activity completes, all pending approvals that were created by any of the Approval Coordinator approval activities are immediately set to No Longer Required. If a single user is called as an approver twice by the same workflow, such as when a single user is both a product approver and an executive approver, any approvals for that user after the first are skipped.
Results
- Approved
- Rejected
- Deleted
- Cancelled
Input variables
Input variables determine the initial behavior of the activity.
Wait for | Indicate what to wait for to indicate that the approval activity is approved or rejected. Options are:
|
When a rejection occurs Only appears if Wait for is set to All child activities to be approved or Any child activity to be approved. | Specify what the coordinator should do when it sees a rejection from any one of the child activities. Options are:
|
Approval script Only appears if Wait for is set to Condition based on script. | If the Wait for variable is set to Condition based on script this script is called to determine how to handle an approval or rejection. The script needs to set the variable answer to , approved or rejected to indicate the overall approval status for this approval. When called, the following variable is available to the script:counts.total = total number of child approval activities that are part of this approval counts.approved = # of child approval activities that approved so far counts.rejected = # of child approval activities that rejected so far counts.requested = # of child approval activities that are pending approval |
Conditions
Approved | The users from the groups have approved the request based on the Wait for rules. |
Rejected | The users from the groups have rejected the request based on the Wait for rules. |
States
Executing | The workflow engine starts the execute function of the activity. |
Waiting | The workflow engine ignores the activity until a specific event to restart the activity is fired. |
Finished | The activity finished running. See the result value for the outcome of the activity. |
Cancelled | This activity, or the workflow that contains this activity, was canceled. |
Error | A JavaScript error occurred. Review the logs for error details. |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 01:12 PM
Hello, ive put it in the workflow but the activity is just skipping over before i can even approve the tasks created by the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 04:19 PM
Hin @HenryD ,
Please refer to below thread:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0693292
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 12:13 PM