Querying the location of a web user in a form display condition

Hi,

In one of our apps, we are toggling the display forms based on the location type a user is attached to. We use the following expression:

instance('locations')/locations/location[@id = instance('commcaresession')/session/user/data/commcare_location_id]/@type = 'optima-product-health-facility'

This works fine for mobile users. But it fails for web users with the following error:

Logic references instance(commcaresession)/session/user/data/commcare_location_id which is not a valid question or value.

What would be the best way to access / query a web user's location in this context?

Thanks!

#it4life

Hi Guillaume,

Web users' locations aren't sent down in the restore, unfortunately, so this information isn't available to applications. They also don't have access to configurable user data.

Would you be able to use mobile workers for this use case? They can be granted permissions to access most stuff on the web.

Hi Ethan,

Thanks for your answer. We could use mobile workers to perform data entry on the web app. The issue would be that a web user would be able to Login As any mobile user. I wanted to avoid that in order to have better control on access rights and better auditing.

Do you confirm using mobile workers is the only way? There's no other workaround?

Thanks,

I can't think of any good workarounds. You could make a lookup table associating web users with locations and reference that, but it'd be a nuisance to maintain.

For what it's worth, you can also disable the "Login-As All Users" permission per role if you have concerns about the usage of that feature.

HI Ethan,

Thanks for your answer. If I disable the "Login-As All Users" feature, then the user can only use the web apps as web user, correct? I won't be able to select which mobile users that web user can login as, right?

Thanks

That's right, users with that permission disabled won't see the "Login As" button in Web Apps - it'll just use their web user.