- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2015 11:38 PM
Hi,
Apart from classic way using client script g_form.removeOption('') and g_form.addOption(''), is there any best practice add and remove options in Choice List?
Thanks
Iyyappan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2015 11:58 PM
Hi Iyyappan,
Although as the whole thread says...addOption, clearOptions and removeOption are the best way to go and i totally agree to that. As far as performance is concerned these functions don't have any noticeable impact. These are service now methods to browser dependency and upgrade support is also there OOB.
Still if you want another option.. here is a code by Harish Murikinati ...This code doesn't remove the option but disable it, options will be there but user wont be able to select them.
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';
}
}
}
Check this thread for more information
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-08-2015 11:21 PM
addOption and removeOption are client side code .. If you are not querying some table and populating the values , dont think there is a performance impact as such
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2015 11:30 PM
Thanks Kalai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2015 11:58 PM
Hi Iyyappan,
Although as the whole thread says...addOption, clearOptions and removeOption are the best way to go and i totally agree to that. As far as performance is concerned these functions don't have any noticeable impact. These are service now methods to browser dependency and upgrade support is also there OOB.
Still if you want another option.. here is a code by Harish Murikinati ...This code doesn't remove the option but disable it, options will be there but user wont be able to select them.
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';
}
}
}
Check this thread for more information
Lock down change states for users with change_management role