How to make a question in a variable set mandatory when a separate variable value becomes true

Wyatt Fudal1
Tera Guru

Hello, 

 

I ran into a roadblock with making a variable mandatory when another variable becomes true. I created a catalog client script but I believe my code is wrong. Has anyone run into this issue? 

Set approver.png

Not mandatory.png

variable and set.png

  

1 ACCEPTED SOLUTION

Narsing1
Mega Sage

Change the type to Onchange and try with this

var m = g_form.getValue("concur").toString();
    if (m.indexOf("true") > -1) {
        g_form.setMandatory("approver_name", true);
    } else {
		g_form.setMandatory("approver_name", false);
	}

Thanks,

Narsing

 

View solution in original post

9 REPLIES 9

The script should work even if concur variable belongs to a different variable set. Ultimately all fields are getting added to the form. Did you check if the script is working for you?

I kept the code but sadly it's not working

Anil Lande
Kilo Patron

Hi,

You have created onLoad client script. I believe when form was loaded the variable was unchecked. 

You can achieve this using onChange Client script that should run on Change of Variable Concur.

But best option would be to create UI Policy instead of client script.

1. Create UI Policy with condition "Concur is True"

and in UI Policy action add action to make your variable mandatory.

 

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Narsing1
Mega Sage

Change the type to Onchange and try with this

var m = g_form.getValue("concur").toString();
    if (m.indexOf("true") > -1) {
        g_form.setMandatory("approver_name", true);
    } else {
		g_form.setMandatory("approver_name", false);
	}

Thanks,

Narsing

 

Thank you, that worked!!!!