Lock down change states for users with change_management role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2015 05:07 AM
Hi,
I am looking to lock down certain states available for selection within the change state field. Please see below options;
I would like for 'ITIL' users to only be able to select the following states;
Draft
Review
Closed
Users with the change_management role should be able to select any of the above states.
Any help with this would be greatly appreciate.d
Kind regards,
Emma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2015 06:06 AM
This is an onchange script on the Type field for your table and view
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if(!isLoading)
{
if(newValue=='Normal') //adding condition for type
{
if(g_user.hasRole('itil') && !(g_user.hasRole('change_management')))
{//add all states that you want to remove
g_form.removeOption('state', '-4');
g_form.removeOption('state', '-3', '');
g_form.removeOption('state', '-2');
g_form.removeOption('state', '2');
g_form.removeOption('state', '-1');
}
}
else if(newValue!='Normal')
{
g_form.clearOptions('state');
g_form.addOption('state', '-4', 'Approval Requested');
g_form.addOption('state', '-3', 'Approved');
g_form.addOption('state', '-2', 'Scheduled');
g_form.addOption('state', '2', 'In Progress');
g_form.addOption('state', '-1' , 'Completed');
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2015 05:23 AM
disableOption();
function disableOption()
{
var fieldName = 'state';
var control = g_form.getControl(fieldName);
if (control && !control.options)
{
var name = 'sys_select.' + this.tableName + '.' + fieldName;
control = gel(name);
}
if (!control)
return;
if (!control.options)
return;
var options = control.options;
for (var i = 1; i < options.length; i++)
{
var option = options[i];
//alert('hello'+ control.id);
control.options[i].disabled = 'true';
}
}
This is code work for disable all choices means un selectable all drop downs . What you can do is give if condition and check user have ITIL role if yes disable particular options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2015 05:29 AM
The below code should work in your case
disableOption();
function disableOption()
{
var fieldName = 'u_status';
var control = g_form.getControl(fieldName);
if (control && !control.options)
{
var name = 'sys_select.' + this.tableName + '.' + fieldName;
control = gel(name);
}
if (!control)
return;
if (!control.options)
return;
var options = control.options;
for (var i = 1; i < options.length; i++)
{
var option = options[i];
alert('hello'+ options[i].value);
if(g_user.hasRole('itil') && (options[i].value == "Draft" || options[i].value == 'Review' || options[i].value == 'Closed'))
{
control.options[i].disabled = 'true';
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2015 06:36 AM
Hi Emma,
You can disable the option based on conditions.
Thanks,
Akash Rajput
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2015 11:10 PM