- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 12:32 PM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:01 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 12:44 PM
you missed "}" at line 9
- function onLoad(){
- var user = g_user.hasRole('it_security');
- if(user){ // you are getting true so no need to do compare
- g_form.setMandatory('risk_comments_1',true);
- g_form.setMandatory('sec_rating_1',true);
- }
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 01:05 PM
That was just a copy\paste error. It's correct in the actual script. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 01:15 PM
- function onLoad(){
- var user = g_user.hasRole('it_security');
- if(user) // you are getting true so no need to do compare
- //g_form.setMandatory('risk_comments_1',true);
- alert('it is working');
- else
- alert('not working');
- //g_form.setMandatory('sec_rating_1',true);
- }
try now just validate if it is giving alert() or not