Set a field value base on another field value while still on the form - UI Policy or Business rule

carlh
Kilo Guru

Hi All,

I was given a task to do something that seems simple but I'm having a tough time figuring out the right way.

I have 2 check boxes.

SID Vendor (True/False)

and

Insurance Required (True/False)

Here's what I need.

When SID Vendor is set to true, I need the Insurance Required box to be set to true.   In a UI Policy/action, I can't set the value. In a Business rule, I can't set the value until insert or submit.

Is there a way to set the Insurance Required value to true while still on the form?   Is that a client script?

Hope that makes sense!

Thank you!

Carl

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Here you go



create an onChange client script on SID vendor field


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue == '') {


  return;


  }


  if(newValue=='true'){


  g_form.setValue('ur second checkbox field name goes here',true);


  }


  else{


  g_form.setValue('ur second checkbox field name goes here',false);


  }



}


View solution in original post

4 REPLIES 4

Abhinay Erra
Giga Sage

Carl,



  You need an onchnage client script for this.


Abhinay Erra
Giga Sage

Here you go



create an onChange client script on SID vendor field


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue == '') {


  return;


  }


  if(newValue=='true'){


  g_form.setValue('ur second checkbox field name goes here',true);


  }


  else{


  g_form.setValue('ur second checkbox field name goes here',false);


  }



}


Works perfect! thank you.   You solved my issue in less tan 10 minutes!


Hi Abhinay,

 

I have almost the similar kind of condition where I have a string field based on which Another field(True/False) needs to be auto-populated. Below is the script I wrote, however that isn't working for me.

TestType(string)

CD: (true/False)

function onChange(control, oldValue, newValue, isLoading, isTemplate){
if (isLoading || newValue == '') {
return;
}
if(newValue=='CDL'){
g_form.setValue('u_cd',true);
}
else{
g_form.setValue('u_cd',false);
}
}

 

Regards,

Venkat