How to make a section of the form visible only to a named user

562
5
07-24-2023 02:18 AM
OliverIshmael
Occasional Contributor

I would like to add an Audit section to my form, that only a specific user can see. Is there a way to do this using Arcade etc?

Also, I would like to add a switch to this section, so that the above user can choose to make it Publicly visible to all. 

0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

For your first question, yes, that's easy enough. You can use the function GetUser, then check the username.

var the_user = GetUser($layer)['username']

return the_user == 'carlsonj9'

Having an expression like this in the conditional visibility setting of the form group will get it to behave as you describe.

jcarlson_0-1690201314539.png

For the second, that seems less doable, but maybe not impossible. How does this "switch" work? Is it something that operates per-feature? Do you have a field to store the value of the switch state?

- Josh Carlson
Kendall County GIS
OliverIshmael
Occasional Contributor

Unfortunately, it doesn't seem to work - in that i can still see the Audit fields. However, as i'm an administrator, i don't know whether this is overriding it?

Regarding the second part with the switch, which would apply to each feature. I was planning to make use of the Field Maps Input Type: switch to control visibility but unsure what Arcade would be required.

0 Kudos
jcarlson
MVP Esteemed Contributor

I expect it would be due to your admin status. Do you have a test user you can use to see if it's working? Or a colleague?

As long as you have a field for "publicly visible" (let's call it "is_public"), you can set the Arcade condition to be

the_user == 'some_person' || $feature['is_public'] == 'yes

 This way the section appears for the specified user no matter what, but to other users if that 'is_public' field is switched to 'yes'.

- Josh Carlson
Kendall County GIS
0 Kudos
OliverIshmael
Occasional Contributor

Hi Josh,

I have now created 2 new users (who are not Admin) to test whether this works:

Ishmael_nrw   (the regular surveyor)

auditor_nrw    (the Auditor)

In the form I have added the following Arcade expression against the Auditor group of fields. The Visibility of Input Type: Group looks like this:

var the_user = GetUser()['username']

return the_user == 'auditor_nrw'

 

When i login as Ishmael_nrw I can still see the Auditor Group element and the fields within it (that should only be visible to auditor_nrw), so it isn't working as intended.  Can you tell me what to try next?

0 Kudos
OliverIshmael
Occasional Contributor

@jcarlson is there anything else i could try?

0 Kudos