- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 07:47 AM
Hello,
As of now our platform just has a check to see if the request was opened by the requested for's manager and it skips the approval and sets the state as approved
What I am looking to do is actually show the manager in the approval tab in the request but have it auto-approved. instead of there being no approvers present.
It will function the same. it is more of a cosmetic change to show that the request was actually approved, even though it will be automatic
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 10:09 AM
Hi,
you could use combination of if + run script activity
Assuming this is for Catalog Item workflow
If Activity
answer = ifScript();
function ifScript(){
if(current.request.opened_by == current.request.requested_for.manager)
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.manager;
gr.comments = 'Auto approved';
gr.insert();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 09:53 AM
I would insert an "approved" approval using workflow.
Activity 1: If Statement
If: Opened By is Manager
Condition: Opened By is same as Request.Requested for.Manager
If yes run activity 2.
Activity 2: Run Script
Run Script: Generate Approval
(function() {
var grApproval = new GlideRecord("sysapproval_approver");
grApproval.initialize();
grApproval.setValue('sysapproval',current.sys_id);
grApproval.setValue('approver',current.opened_by);
grApproval.setValue('state','approved');
grApproval.comments('Auto Approved');
grApproval.insert();
})();
If no, do regular approvals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 10:09 AM
Hi,
you could use combination of if + run script activity
Assuming this is for Catalog Item workflow
If Activity
answer = ifScript();
function ifScript(){
if(current.request.opened_by == current.request.requested_for.manager)
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.manager;
gr.comments = 'Auto approved';
gr.insert();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 01:51 AM
which type of the script used?