- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2023 08:52 PM
Hi Everyone,
I have a requirement like
In workflow we are triggering Manager approval, for some users manager is empty or active false. Handling this situation we decided to check If the Manager is Active or not. If active it goes to manger approval, manger is Inactive or empty need to create one Sctask.
For achiving this I have added If condtion before Manger approval to check Active or not.
I have added the below script in the If Condition:
// replace with the sys_id of the user whose manager you want to check
answer = ifScript();
function ifScript() {
var userSysId = current.requested_for;
var user = new GlideRecord('sys_user');
if (user.get(userSysId)) {
var manager = new GlideRecord('sys_user');
if (manager.get(user.manager)) {
if (manager.active == 'true') {
return 'yes';
}
return 'no';
}
}
}
This script is not checking when the user manger is Active or not, it is working only user manager field is empty.
Can anyone help me on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2023 09:18 PM
try this
no need to query when you can directly dot walk
// replace with the sys_id of the user whose manager you want to check
answer = ifScript();
function ifScript() {
if(current.requested_for.manager.active.toString() == 'false' || current.requested_for.manager.nil())
return 'no';
else
return 'yes';
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2023 09:18 PM
try this
no need to query when you can directly dot walk
// replace with the sys_id of the user whose manager you want to check
answer = ifScript();
function ifScript() {
if(current.requested_for.manager.active.toString() == 'false' || current.requested_for.manager.nil())
return 'no';
else
return 'yes';
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader