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 set assignment group based on variable in a record producer

alexm3
Kilo Expert

Hello,

I'm currently creating a record producer(which creates an incident) and I'm trying to configure an assignment group based on a variable.

The variable name is able_log and has two values, YES and NO.

If the user chooses NO, the incident must be assigned to a group named "Network"

If the user chooses YES, the incident must be assigned to a group named "Service Desk"

Currently, all incidents created from this record producer are assigned to the group "Network" because the variable item on the form is mapped to cmdb_ci field on the incident and that item has the default assignment group as Network, regardless of the value set in able_log

My current script looks like this and it's not working:

if (current.variables.able_log   == 'Yes')

  current.assignment_group.setDisplayValue('Service Desk');

else if (current.variables.able_log   == 'No'){

  current.assignment_group.setDisplayValue('Network);

}

Any ideas would be much appreciated!

Thanks.

Alex

1 ACCEPTED SOLUTION

Ravi Prasad1
Tera Guru

Hi ,



Update the script like below in record producer script



if (producer.able_log   == 'Yes')




  current.assignment_group='sys_id of assignment group';




else if (producer.able_log   == 'No'){


  current.assignment_group='sys_id of assignment group;


}




Let me know if you need any help !!!


View solution in original post

4 REPLIES 4

Ravi Prasad1
Tera Guru

Hi ,



Update the script like below in record producer script



if (producer.able_log   == 'Yes')




  current.assignment_group='sys_id of assignment group';




else if (producer.able_log   == 'No'){


  current.assignment_group='sys_id of assignment group;


}




Let me know if you need any help !!!


Thanks Ravi, it's working !



Alex


Hi Ravi



Best practices says not to use hard coded sys-id. Also current.assignment_group.setDisplayValue('group_name'); is working. Do we face any issues if this method is used?



Thanks,


Bhargava


Rajendra Bagade
Tera Contributor

Hi,



Please try with below code.



if (current.able_log   == 'Yes')



current.assignment_group = sys_id of service Desk;



else if (current.variables.able_log   == 'No'){



current.assignment_group = sys_id of 'Network';  



}