Hide choice options based on role in a field in related list view

janindiadoc_1
Tera Expert

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

1 ACCEPTED SOLUTION

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);
}

Regards
Harish

View solution in original post

13 REPLIES 13

 @janindiadoc_1 make sure your backend value of choice are correct.

Regards
Harish

Its not even showing the alert that I have placed as the first line of the script without any condition. 

Hi @janindiadoc_1 can you share the entire script along with field name selected?

Regards
Harish

Hi Harish,

 

The code worked and I'm able to make the option not selected for the user. Could you please let me know if there is a way to show the message to the user other than alert. I tried spmodal, but its not working.

Hi @janindiadoc_1 you can use any clent side API like g_form.addErrorMessage();

Regards
Harish