how to restrict list view edit of state of change records?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:18 AM
hi,
I want to restrict edit of state fields for list view where only change manager role needs to be able to see closed successful and closed with defects options in state, even the admin should not see these two options, rest of the options of the state field can be editable by anyone.
can anyone help me with this?
in the form view i have written a code for hide on form view but unable to do it on list view?
function onLoad() {
var flag = g_user.hasRole('change_manager');
if(flag != true || g_user.hasRole('admin'))
{
g_form.removeOption('state', '3');
g_form.removeOption('state', '14');
}
}
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:22 AM
Hello,
instead of using onLoad type change to onCellEdit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:23 AM
no this code is not working on on cell edit when i changed to type as on cell edit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:37 AM
Try re-writting your script to something like this:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var flag = g_user.hasRole('change_manager');
if(flag != true || g_user.hasRole('admin') && (newValue == 3 || newValue == 14)){
alert("You cannot perform this action");
false;
}
}
Unfortunately your approach with using g_form will not work as g_form works on the form, not on the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:44 AM
Also this line "var flag = g_user.hasRole('change_manager');" will return true for admin user. Better use g_user.hasRoleExactly('change_manager').