- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2024 09:01 PM
Hi,
I have got a requirement to hide some of the options in the "Status" field of a table based on certain roles in backend form. I was able to achieve that by using an onload client script and hide the options based on the role. This table data is with the status field is shown as an entry in the related list view and there if I expand the dropdown options, all values are coming up.
Is there way to hide the multiple choice options from the field in the related list view as well?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 09:24 PM - edited ‎03-05-2024 09:24 PM
Hi @janindiadoc_1 There is no way to remove choices from list layout, what you can do is you can use onCellEdit client script like below
Create OnCellEdit Client Script:
select field - State
script:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//In Place of "3" add your choice value
if ((newValue == 3) && (g_user.hasRole('admin'))) {
saveAndClose = true; // allow to select choice
} else {
alert('Only admin can select this choice');
saveAndClose = false; // donot allow to select choice
}
callback(saveAndClose);
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2024 06:18 PM
Hi @janindiadoc_1 I just tested g_form.addErrorMessage() donot work in onCellEdit client script due to limitation, the alternate is to use before update Business rule
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2024 10:02 PM
Thanks Harish. It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2024 04:27 AM
Hello @janindiadoc_1
Can you please let me know how you achieved the requirement to hide the choices from the state field in list view. Can you please provide the code and what you created?
thanks,
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2024 04:13 PM
Hi @janindiadoc_1 ,
your script include should be client callable so that you can use Ajax
OR
you create display business rule and use this script
(function executeRule(current, previous /*null when async*/) { // Add your code here var gr = new GlideRecord("RelatedListTable"); gr.addQuery("u_number", current.sys_id); // give correct field name which refers the parent table gr.setLimit(); gr.query(); g_scratchpad.hasRecord = gr.hasNext(); })(current, previous);
onLoad client script
function onLoad(){ if(g_scratchpad.hasRecord.toString() == 'false') g_form.removeOption('Choice Field Name', 'ChoiceOption');
Please refer below thread:
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda