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

Assignment Rule Script not working

rashmianish
Kilo Expert

I have a HR Case being created using a Record Producer. This record producer has a field 'type_of_event', variable type is 'look up select box'. I'm trying to configure an assignment rule which should look at this field value and if the value is 'Event 1', the case should be assigned to Group 1. 

I have written the below script, but the assignment group is not being set.

var event=current.variables.type_of_event;   //tried with type_of_event.toString() too, not working.
if (event == 'sys_id of the event')     //tried giving name of the event too, not working.
{
current.assignment_group.setDisplayValue = 'Group 1';   //tried without setDisplayValue too
}

1 ACCEPTED SOLUTION

rashmianish
Kilo Expert

I found the answer to my question. Firstly thank you Pradeep for trying to help me, much appreciated 🙂

After providing the basic conditions on conditions tab of the Assignment rule (to make sure it won't execute on all), gave the below script in the script section. Worked like a champ.

var quest = new GlideRecord('question_answer');
quest.addQuery('table_sys_id',current.sys_id);
quest.addQuery('question','sys_id of the question you are querying');
quest.query();
while(quest.next())
{
if(quest.value =='sys_id of the value it should query') // A1 certificate of coverage
{
current.assignment_group ='sys_id of the assignment group the request should be assigned';
}
else
{
current.assignment_group='sys_id of the assignment group if condition fails; 
}
}

View solution in original post

6 REPLIES 6

Can you create a test record producer in a personal dev instance and reproduce this issue?

 

- Pradeep Sharma

rashmianish
Kilo Expert

I found the answer to my question. Firstly thank you Pradeep for trying to help me, much appreciated 🙂

After providing the basic conditions on conditions tab of the Assignment rule (to make sure it won't execute on all), gave the below script in the script section. Worked like a champ.

var quest = new GlideRecord('question_answer');
quest.addQuery('table_sys_id',current.sys_id);
quest.addQuery('question','sys_id of the question you are querying');
quest.query();
while(quest.next())
{
if(quest.value =='sys_id of the value it should query') // A1 certificate of coverage
{
current.assignment_group ='sys_id of the assignment group the request should be assigned';
}
else
{
current.assignment_group='sys_id of the assignment group if condition fails; 
}
}