- 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-04-2024 09:22 PM
Hi @janindiadoc_1 .
Can you try these two solution
1. **UI Policies:**
- Create a UI Policy targeting the related list view where you want to hide the options.
- Configure the conditions for the UI Policy to run based on certain criteria (e.g., user roles).
- Add actions to the UI Policy to hide the desired options from the multiple choice field.
- Apply the UI Policy to the related list view.
2. **Client Scripts:**
- Write a client script (onLoad or onChange) that runs when the related list view loads or when certain conditions are met.
- Use JavaScript to target the multiple choice field and hide the desired options based on user roles or other criteria.
- Apply the client script to the related list view.
Here's an example of how you can achieve this using a Client Script:
function hideOptionsBasedOnRole() {
// Check if the user has a specific role (replace 'role_name' with the actual role name)
if (g_user.hasRole('role_name')) {
// Get the multiple choice field element (replace 'field_name' with the actual field name)
var fieldElement = g_form.getControl('field_name');
// Hide specific options (replace 'option_value' with the value of the option you want to hide)
fieldElement.removeOption('option_value');
// Repeat the above line for each option you want to hide
}
}
// Run the function when the related list view loads
hideOptionsBasedOnRole();
Make sure to replace `'role_name'` with the actual role name and `'field_name'` with the name of the multiple choice field. Also, replace `'option_value'` with the value of the option you want to hide. You can repeat the `removeOption()` line for each option you want to hide.
Remember to thoroughly test your implementation to ensure it behaves as expected in different scenarios. Additionally, consider the implications of hiding options from users and ensure it aligns with your organization's requirements and best practices.
Give a thumbsup if this works for you
Regards
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 08:50 PM
Hi, I have already tried this script in the onLoad function, but its not working if I open the dropdown values from the related list. It works when I load the related list form separately.

- 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-11-2024 10:12 PM
I tried the onCellEdit script provided and its not working. I'm not even getting the alert when I try to edit the cell.