How to reference name and surname of a user in CommCare

commcare

I would like to know how to reference in a hidden value the first and last name of a mobile worker in CommCare.

I researched and I was able only to reference the username and location name, but can't find the exact one for first and last name.

Best Answer

In order to do this you need to use something called Custom User Data. In the calculate condition of your hidden variable you can use an expression like this:

instance('commcaresession')/session/user/data/commcare_first_name

And for the last name you can use:

instance('commcaresession')/session/user/data/commcare_last_name

The documentation will show you other examples of how to access things like the user's phone number.