Choice list to show depending upon Roles

Vignesh21
Kilo Guru

HI,

Use case: We have a choice list which has 5 values and i have given on load client script to remove option from the choice list depending upon roles. This is working fine on the form. But on the list view i am able to see all the choice values.

Is there a way we could hide the values on list view depending upon roles.

-Vignesh

1 ACCEPTED SOLUTION

Henrik Jutterst
Tera Guru

I would suggest a new Client Script that runs onLoad.

 

function onLoad() {
	//who to display it for - admin
	var isAdmin = g_user.hasRole('admin');

	if (!isAdmin){
		g_form.removeOption('contact_type', 'integration');
	}
}

View solution in original post

19 REPLIES 19

Already mentioned above. - create an ACL with the list_edit operation to prevent users from editing that field on the list.


Hello Vignesh,



For the list view, in terms of selection, it is all or nothing.



  • Prevent users from editing the choice field via a list_edit ACL
  • Disable list editing for the list
  • Create a business rule to prevent users from setting the choice values. Validation will be based on roles.

is it a good practice to write onload as well as oncelledit both the scripts to achieve the functionality?

thaddeusfreeman
Kilo Expert

You can do what you want by creating a global business rule named table_fieldGetChoices() and then adding the function


function table_fieldGetChoices() to that business rule.



Do a search for Business Rules that contain getChoices in the name for examples.



For example:



function incident_stateGetChoices() {


answer.add("A","a");


}



Will give the the a option in the list.



Hope this helps


Henrik Jutterst
Tera Guru

I would suggest a new Client Script that runs onLoad.

 

function onLoad() {
	//who to display it for - admin
	var isAdmin = g_user.hasRole('admin');

	if (!isAdmin){
		g_form.removeOption('contact_type', 'integration');
	}
}