Does anyone have a way of filtering the Roles, in Knack it is all or nothing and there are times when I just want a user to be able to add or delete from a predefined list of Roles.
I currently use a piece of Java (see below) that was given to me (I am Java illiterate) and it has worked well but unfortunately I have just found out that it allows for a search (as apposed to selecting from the list) to reveal previously hidden Roles.
It would also be much more useful if I could select roles for the Predefined List as apposed to how it is now where I have to define what Roles need to be excluded.
Any help would be gratefully received.
John
$(document).on(âmousedown keyupâ, â#view_3425_field_629_chznâ, function () {
var found = $('ul.chzn-results').find('li');
if (found.length > 0) {
found.each(function () {
var role = $(this)[0].innerHTML;
role = role.replace('<em>', '');
role = role.replace('</em>', '');
if (role === 'Developer'
|| role === 'Admin2'
|| role === 'Admin3
)
$(this).first().removeClass('active-result');
})
}
The approach I generally take when I want a user to be able to affect a role like this is to use a multiple choice field and then use record rules to actually set the user role. This way you can offer any choices you want.
If I create a Multiple Choice field and populate it with the roles I have in âUser Rolesâ for all users, then use Page rules to make âUser Rolesâ = âNew Multiple Fieldâ that would work but there is no way of hiding just some âNew Multiple Fieldâ options, so all options would be visible to the user which defeats my initial object of only showing and allowing a user to add/remove predefined roles.
If I have missed something here please let me know.
If you take the suggestion of using a Multiple Choice field then only add items into the list that you want people to be able to select. The use Record Rules to populate the actual User Role.
If you need more flexibility to filter the list of options then set up an Object as a lookup table with whatever additional fields you need to filter the list for users. Then again use record rules to set the value.
One thing you should be aware of is that this approach will not deal with cases where users need to be assigned multiple user roles. In general Multiple Choice and Many to Many connection fields can have values added or removed from them in record rules but the User Roles field does not support this for some reason (and was the first field I tried to use add / remove with of course).
If you do need to cater for this, all is not los because you can do it with Integromat.
Hi Julian, thanks for taking the time with this, I specifically needed the ability to add a role to existing roles in a controlled environment, unfortunately this approach doesnât allow for that and I have found nothing that will although I have yet to look at Integromat
OK - Integromat can do that but it is not necessarily a day 1 new user type of âScenarioâ to create (although not that hard. This is basically because the Knack module in Integromat needs the list of roles to be set in an Array - feel free to book a Zoom with me if you would like me to show you how: