How to make Yes/No field populate elsewhere?

Eli Hurst
Kilo Contributor

I have a Yes/No variable, and the entry needs to get populated in 2 Yes/No read-only boxes farther down the form. Is there a simple script to make this happen?

1 ACCEPTED SOLUTION

Good point! It's a Yes/No field so there's only 2 choices so that'll do.

Need to check "Reverse if false" in that case.

View solution in original post

12 REPLIES 12

shloke04
Kilo Patron

Hi @Eli Hurst 

When do you want the values to be populated on those red only boxes?

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

So on the form, they select yes or no based on their financial position. Hitting yes or no should populate 2 yes/no variables farther down the form immediately, and change to 'No' if they select no to the original statement. The read only boxes have some label text explaining that "By hitting yes, you agree to law X, Y, and Z..." but its more or less a glorified way of showing they are agreeing to it. 

Hi @Eli Hurst 

You can handle this using a single On Change Catalog Client Script on your catalog item and use the script as below:

Script:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	if(newValue == 'Yes'){
		g_form.setValue('Variable1','Yes');
		g_form.setValue('Variable2','Yes');
	}else if(newValue == 'No'){
		g_form.showFieldMsg('Variable name 1','Your message here','info');
		g_form.showFieldMsg('Variable name 2','Your message here','info');
	}

   //Type appropriate comment here, and begin script below
   
}

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hitoshi Ozawa
Giga Sage
Giga Sage

Even though it would be awkward to set values to fields using UI Policy, UI Policy can be used.

In this case, it would be necessary to create 2 UI Policies.

UI Policy 1:

Catalog Condition: field1 is Yes

Reverse if false: uncheck

function onCondition() {
    var flg = g_form.getValue('field1');
    g_form.setValue('field2', flg);
    g_form.setValue('field3', flg);
}

UI Policy 2:

Catalog Condition: field1 is No

Reverse if false: uncheck

function onCondition() {
    var flg = g_form.getValue('field1');
    g_form.setValue('field2', flg);
    g_form.setValue('field3', flg);
}

Execution results are the same as with Client Script.

Couldn't you make it on the same UI script, and have one piece on the Execute if True and one on the Execute if False?