Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader