The CreatorCon Call for Content is officially open! Get started here.

How to auto populate 'assigned to' field based on the assignment group on incident table

sunil7
Giga Expert

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?

1 ACCEPTED SOLUTION

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Kieran Anson
Kilo Patron

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?

Hi Kieran,

Yes there are 4 members in that group and i want randomly select the user in assigned to.

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur ,

Can you please provide me the code for random assignment in assigned_to field