Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to auto populate Assignment group and assigned to

Alon Grod
Tera Expert

Hi,

 

I have the record producer 'Create Incident' which create a record in incident table. On the incident table i have the fields assignment group and assigned to. How can I auto populate these fields using the record producer based on caller_id value from the record producer?

1 ACCEPTED SOLUTION

BharathChintala
Mega Sage

@Alon Grod you can write something like this in Record producer script

BharathChintala_0-1675691674881.png

 

var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", caller);
gr.query();
if (gr.next()) {
    if (gr.location == 'india') { // here you can check anything from user record and based on that you can set Assignment group and to.
        current.assignment_group = gs.getProperty('property name'); // declare a properrty of group sysid and call property here
        current.assigned_to = gs.getProperty('property name'); // declare a properrty of user sysid and call property here
    } else if (gr.location == 'usa') {
        current.assignment_group = gs.getProperty('property name'); // difine different property for other group related to USA
        current.assigned_to = gs.getProperty('property name'); // declare a different properrty of user sysid and call property here
    }
}
 
or else
go to assignment rules
BharathChintala_1-1675691745986.png

Define like this in conditions

BharathChintala_2-1675692133061.pngBharathChintala_3-1675692149547.png

 

In action give group name.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

View solution in original post

10 REPLIES 10

BharathChintala
Mega Sage

@Alon Grod you can write something like this in Record producer script

BharathChintala_0-1675691674881.png

 

var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", caller);
gr.query();
if (gr.next()) {
    if (gr.location == 'india') { // here you can check anything from user record and based on that you can set Assignment group and to.
        current.assignment_group = gs.getProperty('property name'); // declare a properrty of group sysid and call property here
        current.assigned_to = gs.getProperty('property name'); // declare a properrty of user sysid and call property here
    } else if (gr.location == 'usa') {
        current.assignment_group = gs.getProperty('property name'); // difine different property for other group related to USA
        current.assigned_to = gs.getProperty('property name'); // declare a different properrty of user sysid and call property here
    }
}
 
or else
go to assignment rules
BharathChintala_1-1675691745986.png

Define like this in conditions

BharathChintala_2-1675692133061.pngBharathChintala_3-1675692149547.png

 

In action give group name.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala