onLoad catalog client script not running

M_iA
Kilo Sage

I have a simple need to only load a variable set if the logged in user has a specific role. However, for some reason which i cant work out, it doesnt run!

function onLoad() {

    var hasRole = g_user.hasRole('sn_esm_user_admin');
    if (hasRole == true) {
		g_form.setDisplay('query_on_behalf_of', true);
    } else {
		g_form.setDisplay('query_on_behalf_of', false);
    }

}

Have tried all of the individual fields as well, but no luck!

Any ideas?

1 ACCEPTED SOLUTION

M_iA
Kilo Sage

I scrapped the client script completly and went with this on the individual variables within the variable set:

M_iA_0-1724948795690.png

This worked and for people who want no code, this is the solution

View solution in original post

6 REPLIES 6

Sandeep Rajput
Tera Patron
Tera Patron

@M_iA setDisplay() can only be used to hide a field on the form. It can't be used to hide a variable set.

Hi @Sandeep Rajput 

As per the above, I also tried this at the individual field level. Have also tried with setVisible().

@M_iA Is your field a mandatory field on the form? If yes then you can't hide a mandatory field on the form either using a client script or a UI Policy. Here is the evidence.

Please mark the response helpful and accepted solution if it manages to answer your question.

Screenshot 2024-08-29 at 8.01.59 PM.png

No, none of the fields are mandatory