- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 04:33 PM
Hello,
I am trying to hide a choice list value Category(category) on the work order form from a specific role.
I tried creating a onLoad client script but I must be doing something wrong because it is not working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 05:32 PM
uncomment the line number 6 and check logged user has role or not .
What it is giving . Is it true or false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 06:01 PM
Glad to here that i can help you.
please mark my response as accepted solution & helpfull so that other can take help .
And close the thread.
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 06:47 PM - edited 01-12-2024 06:49 PM
Do like this
- Remove the Option "Electrical" from the category choice list from the backend
- add the below code to Onload
function onLoad() {
//Type appropriate comment here, and begin script below
if (!g_user.hasRole("wm_security")) {
g_form.addOption("category", "electrical", "Electrical");
var control = g_form.getControl("category");
var options = [];
for (var m = 0; m < control.options.length; m++) {
var op = {
"text": control.options[m].text,
"value": control.options[m].value
};
options.push(op);
}
options = options.sort(function(op1, op2) {
if (op1.text > op2.text) return 1;
if (op1.text < op2.text) return -1;
});
g_form.clearOptions("category");
for (var b = 0; b < options.length; b++) {
g_form.addOption("category", options[b].value, options[b].text);
}
}
}
Thanks,
Narsing
