Catalog Client Script not making field mandatory

stephaniet
Kilo Expert

Hi everyone,

I have the following Catalog Client Script to make a field mandatory if a user has a specific role.

function onLoad(){

var user = g_user.hasRole('it_security');

if(user == true){

g_form.setMandatory('risk_comments_1',true);

g_form.setMandatory('sec_rating_1',true);

}

}

For some reason it is not making the field mandatory even though the user does have the role.   I have another script to make the same fields read only if the user does not have that role, and that one is working just fine.

Any help is appreciated!

1 ACCEPTED SOLUTION

ok the first thing i would do is disable all other client scripts and ui policies on the item... then see if it works right.. if so you have a conflict..enalble them one at a time and see which one breaks your client script and why.


View solution in original post

7 REPLIES 7

Harsh Vardhan
Giga Patron

you missed "}" at line 9




  1. function onLoad(){  
  2. var user = g_user.hasRole('it_security');  
  3.  
  4.  
  5. if(user){   // you are getting true so no need to do compare
  6. g_form.setMandatory('risk_comments_1',true);  
  7. g_form.setMandatory('sec_rating_1',true);  
  8. }  
  9. }

That was just a copy\paste error.   It's correct in the actual script.   Thanks!


  1. function onLoad(){
  2. var user = g_user.hasRole('it_security');
  3. if(user) // you are getting true so no need to do compare
  4. //g_form.setMandatory('risk_comments_1',true);
  5. alert('it is working');
  6. else
  7. alert('not working');
  8. //g_form.setMandatory('sec_rating_1',true);
  9. }

try now just validate if it is giving alert() or not