Script for auto assignment of approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 08:25 PM
I don't have scripting knowledge in ServiceNow but I need to create a script for approvals that will allow to send approvals in a round robin style to a set of users for a specific group. The logic that I have for this script is below:
1. declare a variable to store the last approver
2. if last approver is equals to Alice then last approver is now BOB
3. if last approver is equals to BOB then last approver is now Charles
4. else approver is Alice
I found an existing script in our instance that is being used like this and it uses sys ID's so I assume I should be using sysID.
I have the below but i am not really familiar with the syntax and I cannot get any resource from the internet on this:
var result = setUserAndGroup(recordGr);
users = result.users;
groups = result.groups;
var l_approver = string
/**
* This function serves to return a list of approver users and groups.
* The Vulnerable Item record provided in the change approval request is added as the input parameter to this script.
* The function should return an object containing comma separated sys_ids for users and groups with role sn_vul.exception_approver.
*/
function setUserAndGroup(recordGr) {
// Add any logic here to construct your script as necessary.
if (lappr = 'alice') {
return {
users: "c82c16d91bf4b85085e055352a4bcb4f", //bob
groups: "",
lappr_approver = "bob"
};
} else if (lappr == bob) {
return {
users: "b3e561db1bfea050d63e74c51a4bcbe8", //charlie
groups: "",
lappr_approver = "charlie"
};
} else {
return
users: "1bc188afdc6301005d7bc76a9100b9e9", //alice
groups: "",
lappr = "alice"
}
}
I appreciate if you can help me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 01:29 PM
any tip with the syntax? i can probably figure it out. Or maybe a resource where I can learn scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 10:54 AM
is there a free resource where I can learn Service now Scripting? Or maybe a reference list?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 02:36 PM
Hi there,
Some of the useful links i would suggest are below
Best tutorial for servicenow javascript by @chuckm. This would be very good. All the videos from Chuck Tomasi is very good.
https://www.youtube.com/watch?v=62Nabpb94Jw&list=PL3rNcyAiDYK2_87aRvXEmAyD8M9DARVGK
saas with snow development tutorials
https://www.youtube.com/watch?v=axYFU6O0b8U&list=PLzTvAeLiW8AeO2Ep-qgufgOdLJ5UoA4hf
udemy
https://www.udemy.com/course/servicenow-201-development/
Now learning Application developer course (need partner portal access )
Please mark helpful/like, if the solution is inline with your expectation.
Regards,
Gagan k