How to display choices for a field based upon if the current user is part of an assignment group in List view ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:01 AM
Trying to display choices for a particular field in List view if the current user is part of a specific assignment group. Created choices for the field through Dictionary entry and tried using a query BR to check of the user is part of the assignment group or not and then set the choices as inactive, however not able to update the fields. Any pointers will be helpful.
Script:
var rec = new GlideRecord('sys_choice');
var queryString = 'element=state^name=sc_task';
rec.addEncodedQuery(queryString);
rec.query();
while (rec.next()) {
if (gs.getUser().isMemberOf('Help Desk')) {
rec.inactive = false;
} else {
rec.inactive = true;
}
rec.update;
}
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:23 AM
Hi Sarin, did you try using onCellEdit client script where you can use script to remove options/choice and display choices you need.
Link to docs: search for onCellEdit
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:33 AM
Hi
Had tried, it didn't work.
Thanks much!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 08:43 AM
can you share the OnCellEdit script that you tried?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:38 AM
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if (g_scratchpad.memberOfGrp == true) {
g_form.removeOption('state', 'Cancel');
g_form.addOption('state', 'Acknowledged', 'Acknowledged');
g_form.addOption('state', 'In Progress', 'In Progress');
} else {
g_form.removeOption('state', 'Acknowledged', 'Acknowledged');
g_form.removeOption('state', 'In Progress', 'In Progress');
g_form.addOption('state', 'Cancel', 'Cancel');
}
callback(saveAndClose);
}