if g_form.isNewRecord set assignment group

DIVI1
Tera Expert

I need to declare value of assignment group in 'Problem' Table. 

And here is a problem, cause I just want to declare assignment group only for new records, while updating change of the assignment group should be possible.

That's how my client script look like :

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
 if(g_form.isNewRecord()){
   g_form.setValue('assignment_group', '6ae3f5b21b479850bf327bb5464bcb45');
}
}

After when I'm trying to create a Problem I've got message below assignment group field:

DIVI1_0-1695814923200.png

 

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

I would suggest you to use a Business rule. create a before insert business rule and use the below code:-

 

current.setValue('assignment_group', '6ae3f5b21b479850bf327bb5464bcb45');

 

Please mark my answer as correct based on Impact.

View solution in original post

14 REPLIES 14

Hi @DIVI1 

 

Then you should use the default value instead of a BR.

One less logic to evaluate after insert, and you will see the value before the record is saved the first time.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Actually it doesn't work like that, cause If I'll declare default value, The user is still able to change it before save ticket

If it's not supposed to change, why not set the field read only?

A default value always only is for new records 

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

I mean it should be possible to change in the future, while updating the ticket for example, but not while creating.

In that case, you would need a onLoad Client script, or UI Policy script:

 

if(g_form.isNewRecord() ){

g_form.setReadOnly("assignment_group",'true');

}

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.