Auto Approval using Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 01:24 AM - edited 01-13-2023 01:32 AM
Hello ,
I am trying to get Auto Approval using condition based script in approval user activity If the caller is same as the approver , I 'm using below script but its not working and according to ServiceNow Community it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 01:44 AM
Hello @Shreya Nagar ,
You can have the if activity along with run script activty. Please find the below code
If Activity
answer = ifScript();
function ifScript(){
if(current.request.opened_by == current.request.requested_for)
return 'yes';
else
return 'no';
}
Output of Yes to Run Script:
Run Script Below:
var gr = new GlideRecord('sysapproval_approver');
gr.initialize();
gr.sysapproval = current.sys_id;
gr.state = 'approved';
gr.approver = current.request.requested_for;
gr.comments = 'Auto approved';
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 01:48 AM
One of the ways to achieve this is using Approval Action workflow activity.
After workflow activity, create a Run Script to evaluate if the caller is same as the approver, store the answer in scratchpad and based upon it utilize Approval Action activity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 02:45 AM
Hey Omkar ,
Can you share me the script ?