Copy the choice values to string using ui policy

saini
Tera Expert

I have a table with 2 string fields as field1 and field2, and I have 2 choice fields as field3 and field4. Now when we make any changes in filed3 and field4 it should be copied to field1 and field2 respectivey. How can we do this using UI policy?

Thanks

1 ACCEPTED SOLUTION

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading ) {
      return;
   }

   //Type appropriate comment here, and begin script below
   g_form.setValue('field1',newValue);//sets value of field3 to field 1whenever field3 changes
	
}

View solution in original post

4 REPLIES 4

RaghavSh
Kilo Patron

1.You need to write two UI policies in field 3 and field 4 with condition field3 changes and field 4 changes accordingly.

2.click on "advanced view" in related links

3. under script tab check run script.

4.In "Execute if true" write g_form.setValue('field1', g_form.getValue('field3'));

5. do same in other UI policy.

 


Raghav
MVP 2023

@saini were you able to achieve this?


Raghav
MVP 2023

Community Alums
Not applicable

It is better to use onChange Client Script instead of UI policy.

 

1.Write two change Client scripts on Filed values Feild3 and Field 4.

2.In Script section you assign field1 = newValue; and Field2= newValue; respectively.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   g_form.setValue('field1',newValue);//sets value of field3 to field 1whenever field3 changes
	
}

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading ) {
      return;
   }

   //Type appropriate comment here, and begin script below
   g_form.setValue('field1',newValue);//sets value of field3 to field 1whenever field3 changes
	
}