- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 11:14 PM
I have a request where the user wants that if the requested by is the approver himself, the request should skip the approval and go to next level of approval. is that possible to achieve via client script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 11:33 PM
Not really. The workflow generates the approval and you can't block that with a client script.
I'd suggest modifying the workflow even if it's just for one item as you can also add a condition for "if(current.item == "your_cat_item_sys_id")" and have it affect only that one item and otherwise always ask for the approval from requested by as well.
Any workarounds for that would be confusing for anyone who'd later try to figure out why it works that way if it's not included in the workflow.
Technically you could try creating a before insert BR on sysapproval_approver table which prevents insert if approver == requested by, but I'm not sure how the workflow will behave in that scenario and again, it's confusing trying to figure out later if someone doesn't know about the BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 11:22 PM
I'll assume your approval is generated from a workflow?
In the workflow you can simply add an "if" action.
If the requested by is the same person who would be selected as the approver, then skip over the approval action. Otherwise ask for the approval.
You can also do this in the approval action by writing a script that sets the approver only if they're not the requested by person. If no approver is set the approval action simply behaves as if approval was given, but that might cause confusion if anyone looks at the workflow and sees that but no approvers on the ritm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 11:24 PM
Yes the approval is generated via workflow but i don't want to modify the workflow. It's jus 1 catalog item where i want to make the change and is it possible via client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 11:33 PM
Not really. The workflow generates the approval and you can't block that with a client script.
I'd suggest modifying the workflow even if it's just for one item as you can also add a condition for "if(current.item == "your_cat_item_sys_id")" and have it affect only that one item and otherwise always ask for the approval from requested by as well.
Any workarounds for that would be confusing for anyone who'd later try to figure out why it works that way if it's not included in the workflow.
Technically you could try creating a before insert BR on sysapproval_approver table which prevents insert if approver == requested by, but I'm not sure how the workflow will behave in that scenario and again, it's confusing trying to figure out later if someone doesn't know about the BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 12:12 AM
@Nafeesa bashir If you don't want to modify the workflow then you can change the state of approval record to approved from script and add comment to the approval record that as the requested by user is same as approver this approval got auto approved.
When the state is changed to approved, the workflow will detect the change and proceed further.
Hope its helpful.
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023