Help with a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2024 08:40 AM
I have a catalog item with a reference field to the sys_user table called 'Existing Approver'. The requirement is if the 'Existing Approver' is active I would like an approver request to go to the 'Existing Approver', but if the 'Existing Approver' is inactive, I would like it to by pass this step and go to the next step. How should I add this on the workflow? Any help with be appreciated.
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2024 08:56 AM
Hi @Jen11
So before ask for approval , check teh vale coming from variable by dot walk active True/ false if false you same user as approver else go to next
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2024 09:10 AM
@Jen11 , you need to add an If condition before the Approval Activity and Validate the Approver whether the user profile is Active or Inactive in the Script , use the following script
answer = ifScript();
function ifScript() {
var aprvr = current.variables.who_are_you_requesting_this_software_for.manager;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',aprvr);
gr.query();
if (gr.next()) {
if(gr.active ='true'){
return 'yes';
}
return 'no';
}
}
Join Yes to the Approval Record and Join no to the Activity which is After Approval as we are Skipping for Inactive Users
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2024 09:17 AM - edited ‎02-02-2024 09:19 AM
Create the approval activity and check on advance and use below script to trigger approval if Existing Approver is active else we can mark record as approved.
Add below script to the approval activity
answer =[];
var user = new GlideRecord('sys_user')
user.addActiveQuery();
user.addQuery('sys_id', current.variables.existing_approver)
user.query()
if(user.hasNext())
{
answer.push(current.variables.existing_approver)
}
Please let me know if it is working or not