Hiding a modal button for specific groups

Hi all:
I have created a modal button that I only want to be visible if the user is not in one of two groups. I have put the following logic into the "Hidden" parameter but when I preview the app, I don't see the button at all (I should, as I'm not part of one of the excluded groups).

{{current_user.groups.map(group => group.name).includes('View Only') || current_user.groups.map(group => group.name).includes('Limited Editor')}}

Is it not possible to hide a modal button using logic? I'd rather not have to create a workaround with a regular button and javascript if I can avoid it.


@amylynnelee Welcome to the forum...
{{current_user.groups.map(group => group.name)}} is an array but I don't believe you can both map and use includes all in one go...
perhaps store the result in a temp state (state1 or any name you call it) and then test
{{state1.value.includes('View Only' || state1.value.includes('Limited Editor')}}

I like ScottR's approach, but I think you can also do this using the formatDataAsObject function with some and/or logic:

{{formatDataAsObject(current_user.groups).name.some(x=> !x.includes('Payroll SUPERVISOR') && !x=='admin')}}

I currently have this type of setup so certain table fields can remain editable to some users but not others, as well as for visibility on different navigation headers within an app.

1 Like

Thanks @ScottR! This worked perfectly!

Thanks @pyrrho, I'm going to try your recommendation, as well!

1 Like