Using JSUtil.nil in business rule

sigmachiuta
Kilo Guru

I am trying to use JSUtil.nil in a business rule but it does not assign to the group.   If i directly set the assignment_group to group 1 it will insert the record correctly.   Is there a reason JSUtil.nil does not work in a BR?

grTest.priority = 2;
grTest.approval = "approved";
if(!JSUtil.nil(Group1)){
grTest.assignment_group = Group1;
}
else if (!JSUtil.nil(Group2)){
grTest.assignment_group = Group2;
}
grTest.insert();
1 ACCEPTED SOLUTION

poyntzj
Kilo Sage

why not use JSUtil.notNil() instead of if(!JSutil.nil())


View solution in original post

8 REPLIES 8

srinivasthelu
Tera Guru

I am sorry , Could you please elaborate more on this?


if i directly set the assignment group grTest.assignment_group = Group1; or grTest.assignment_group = Group2;


when the task is created it populates with the correct group.   I am wanting to check if group1 is blank assign to group 2 but when i try using !JSUtil.nil the group does not populate or the task is not created when the BR runs.   So I thought I was doing something wrong bc i dont understand why I cant get this to populate the correct group if one is blank.


poyntzj
Kilo Sage

why not use JSUtil.notNil() instead of if(!JSutil.nil())


Or may it is working properly and it is not setting anything because the values are empty?



Have you tried printing logs?



One more guess, Which version of the instance you are running on ? are you doing this from any scope?