- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2021 12:14 AM
Hi everyone,
I have a requirement to auto populate 'assigned to' field based on Assignment group(Ex. Licence Varification) on incident table. How to achieve this please help?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2021 02:21 AM
Hi,
For random assignment you can use this
Before Insert BR
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var arr = [];
var member = new GlideRecord('sys_user_grmember');
member.addQuery('group.name','SAM-LicenseVerification');
member.query();
while(member.next()){
arr.push(member.getValue('user'));
}
var randomNumber = Math.floor(Math.random() * Math.floor(4));
current.assigned_to = arr[randomNumber];
})(current, previous);
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
‎01-18-2021 01:28 AM
Hi Sunil,
Assignment groups tend to have more than one user assigned, is this not the case? Or are you wanting it to randomly choose a person?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2021 01:58 AM
Hi Kieran,
Yes there are 4 members in that group and i want randomly select the user in assigned to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2021 01:33 AM
Hi Sunil,
If you always sure that the group will be SAM-LicenseVerification then there are couple of ways to auto-populate the Assigned to user
1) Assignment Rule on incident table
2) Before insert BR on incident table
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
‎01-18-2021 02:09 AM
Hi Ankur ,
Can you please provide me the code for random assignment in assigned_to field