Auto set of assignment group based on conditions not working.

Alok21
Giga Expert

Hi Team,

I am trying to auto set assignment group based on conditions but it is not working.

The requirement is while creating a new case if Product (Reference field to Product table)= 'Alokproduct' and Feature(Reference field to Product table) = 'Alok feature', then the Assignment group for that case should be auto Populated with "Case support group". I have created a before insert BR with below code. 

if(current.isNewRecord()){
var product = current.getValue('product');
var feature = current.getValue('u_feature');
if (product == 'Alokproduct' && feature == 'Alok feature'){
current.assignment_group = '9d55d96f292200da6f08c6eb3ee442'; 
}

}

Note: There is already an assignment rule which is auto populating the assignment group on a different condition. My condition is different and i want to over write the group when my conditions are satisfied.

Can someone please assist?

 

Regards,

Alok sahu




1 ACCEPTED SOLUTION

Community Alums
Not applicable

As the assignment rule you mentioned is already in place, you will need to keep this BR to overwrite it

because assignment rules trigger after the form is submitted.

 

If you still want the users to see the change client side(on the form) then additionally you will have to write 2 onChange Client Scripts.

1. for product field:

if(newValue == 'sys_id of Alokproduct' && feature == 'sys_id Alok feature')

g_form.setValue('assignment_group','9d55d96f292200da6f08c6eb3ee442');

 

2. for feature field:

if(newValue == 'sys_id of Alok feature' && product== 'sys_id Alokproduct')

g_form.setValue('assignment_group','9d55d96f292200da6f08c6eb3ee442');

 

Please mark as correct/helpful if this helps! 🙂

Thanks 

DR

View solution in original post

25 REPLIES 25

Shashikant Yada
Tera Guru

Can you try below code

if(current.isNewRecord()){


var product = current.product.getDisplayValue();
var feature = current.u_feature.getDisplayValue();


if (product == 'Alokproduct' && feature == 'Alok feature'){


current.assignment_group = '9d55d96f292200da6f08c6eb3ee442';
}

}

 

Hi,

I tried with this script but not working.

Any other solution?

 

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

please ensure that these rules are respected in your instance:

Data lookup rules, assignment rules and business rules run in the following order:

  1. Data lookup rules take precedence over assignment rules.
  2. All before business rules that run on a record insert with an order value less than 1000.
  3. The first assignment rule with the lowest execution order and matching condition.
  4. All before business rules that run on a record insert with an order value greater than or equal to 1000.
  5. All after business rules that run on record insert.

https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/task-table/concept...

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Hi,

So if the assignment group is already set with a different group through Data Lookup, then if my condition is met it should set the new group or it remains with the old group?

Regards,

Alok sahu