Catalog Client Script On Change True/False Field Question

richelle_pivec
Mega Guru

I have been working on this script for an hour or so, and I just can figure out what I'm missing. I have two fields on a record producer. One is "Does this question relate to Epic?" If they check the box (True), I want the script to fill a certain value into the 'contact_type' field. if they do not check the box (False), I want the value to say something else. I realize I'll probably need to do an On-Load script to get that other value (or make it the default value), but for now, I'm just trying to get the on-change script to work.

Here is the script I have:

On change of "u_ss_epic" field:

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

var epc = g_form.getValue('u_ss_epic');
var cnt = g_form.getValue('contact_type');
 
 if (epc=='true') {
      
  g_form.setValue(cnt, "Self-service - Epic Direct");
 }
 else {
  
  g_form.setValue(cnt, "Self-service");
 }

}

The latest error I am getting is this:

onChange script error: TypeError: id is undefined function h_776645a213c91700ef305eff3244b07a(control, oldValue, newValue, isLoading) { var epc = g_form.getValue('u_ss_epic'); var cnt = g_form.getValue('contact_type'); if (epc=='true') { g_form.setValue(cnt, "Self-service - Epic Direct"); } else { g_form.setValue(cnt, "Self-service"); } }

Thanks for your help,

Richelle

 

1 ACCEPTED SOLUTION

rahulpandey
Kilo Sage

Hi,

Always, try to maximize UI policies. It works in most of condition evaluation even with reference fields 🙂

Condtion : Does this question relate to Epic? = true;

Script if true: 

g_form.setValue('contact_type', 'Self-service - Epic Direct');

Script if false: 

g_form.setValue('contact_type', 'Self-service');

check reverse if false true.

 Check onload true;

View solution in original post

3 REPLIES 3

Mike Patel
Tera Sage

try

function onChange(control, oldValue, newValue, isLoading) {
	var epc = g_form.getValue('u_ss_epic');
	if (epc=='true') {
		g_form.setValue('contact_type', 'Self-service - Epic Direct');
	}else{
		g_form.setValue('contact_type', 'Self-service');
	}
}

rahulpandey
Kilo Sage

Hi,

Always, try to maximize UI policies. It works in most of condition evaluation even with reference fields 🙂

Condtion : Does this question relate to Epic? = true;

Script if true: 

g_form.setValue('contact_type', 'Self-service - Epic Direct');

Script if false: 

g_form.setValue('contact_type', 'Self-service');

check reverse if false true.

 Check onload true;

This worked wonderfully well. I think this is the first time I've used a script in a UI Policy. I didn't even realize I could. I'll definitely tuck that tidbit away for future use.

thanks much,

Richelle