Setting value of reference fields using Business Rule

tyagisu
Mega Expert

Hello!

I am trying to set some fixed values in reference fields like assignment group, location, primary configuration item. Our requirement is when incident tickets are generated from Dynatrace Integration, assignment group, location and CI should have the values X,Y and Z auto set. I tried using onLoad client script to set up these values, but it didn't work as expected. The onLoad script would work only after opening the tickets, hence I thought of using Before Business Rule.

We cannot set these values in Integration script itself because of some other requirement conflicts.

Here is my script:

(function executeRule(current, previous /*null when async*/) {
current.contact_type = "X";
current.location = "Y";

current.assignment_group = "Z";
current.update();
})(current, previous);

Any help would be highly appreciated!

Thanks,

Su

1 ACCEPTED SOLUTION

Do you have group by name Z in your sys_user_group table. Please pass the exact name of group. Write before insert/update BR.

EX: Network is a group name

current.assignment_group.setDisplayValue('Network');

View solution in original post

9 REPLIES 9

Anurag Tripathi
Mega Patron
Mega Patron

 Use 

current.setValue('assignment_group','Z');

-Anurag

Shweta KHAJAPUR
Tera Guru

Hi,

If your fields are Refere fields then try using below code,

(function executeRule(current, previous /*null when async*/) {
current.contact_type = "X";
current.location.setDisplayValue("Y");
current.assignment_group.setDisplayValue("Z");


})(current, previous);

SaiRaviKiran Ak
Giga Guru

As you are setting values to the reference field make sure X,Y and Z values in your business rule should be sys_id's.

Something like this?

current.setValue('assignment_group','sys_id of group');