Hiding Radio buttons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2015 03:31 AM
Is there any way to hide radio button (question choice under a MULTIPLE CHOICE variable type) for business users (non-ITIL users)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2015 03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2015 04:18 AM
Hi Moulik,
Thanks for the threads. But since my requirement is more of a user-role specific, UI policies wont work out. I tried the below client script and it removed the whole multiple choice variable including label from the service catalog.
function onLoad() {
var isitil = g_user.hasRole('itil');
if (!isitil)
{
var a = g_form.getControl('safe_request_type');
var b =$(a).up(1).up(1).childElements().each(function(value,index){ if(value.innerHTML.indexOf('Architecture') != -1){ $(value).hide(); } });
}
}
Since, I need only one radio button (from the list of 3 radio button choices) to be invisible for non-ITIL, the above script doesn't seem to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 06:46 PM
I know this is a very old question, but I thought I'd chime in, just in-case someone else is looking for the answer.
Unfortunately ServiceNow hasn't given us an easy option, but here's what you need:
//This assumes that your variable is named "safe_request_type" and your option value is "architecture"
function onLoad() {
if (!g_user.hasRole("itil")){
showRadio("safe_request_type","architecture",false);
}
function showRadio(strVarName, strOption, bVisible){
var myOptions = g_form.getControl(strVarName).up(1).getElementsByTagName("label");
for (var i=0;i<myOptions.length;i++){
var element = myOptions[i].getElementsByTagName("input")[0];
if (element.value == strOption){
element.hidden=!bVisible;
myOptions[i].hidden=!bVisible;
break;
}
}
}
}