Calculation error for hidden value with instance('commcaresession')

Hi there,

I am able to use the lookup table feature to reference location by org level/structure in a different app in the same project space, but I a developing a new app and am getting an error for a hidden value I use to make this possible:

The hidden value calculation is: instance('commcaresession')/session/user/data/commcare_location_ids

The error message is: Calculation Error: Error in calculation for /data/user_data/commcare_location_ids Logic references instance(commcaresession)/session/user/data/commcare_location_ids which is not a valid question or value.

Thanks so much for your help,

The app will need logged in users to have assigned location data for that expression to work, but it doesn't look like you are logged in as a mobile user who could have location data assigned.

If you'd like the app to work with or without the location data being present for a given user, you could check to ensure that the value exists first, IE:

if ( count(instance('commcaresession')/session/user/data/commcare_location_ids) > 0, instance('commcaresession')/session/user/data/commcare_location_ids, '' )

-Clayton

1 Like

Thank you so much Clayton!