Generating a Unique ID for beneficiaries


im trying to add a beneficiary ID generator in an APP

the 1st step according to the below page is to assign each user a prefix value

the prefix value is configured as a User Property in Edit User Fields which i called “user ID” and creating a hidden value with the following Xpath expression: instance(‘commcaresession’)/session/user/data/custom_user_data_name

im getting every error under the sun because Commcare isnt reading my User Property

is there a work around?

thanks so much!

The example


will reference a user property called custom_user_data_name. You’ll need to change that last part of the expression to the property name for your new “User ID” property - whatever is in the first column on the “Edit User Fields” page (it can’t contain spaces). For instance, it might look like


Thank you Ethan
i should have been more specific , my bad

the user property was set up like : MAMI_user_code

the Xpath in the hidden value is: instance(‘commcaresession’)/session/user/data/MAMI_user_id

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

is there something else im missing ?

your support is much appreciated

I see. That does look like it should work under normal circumstances. Are you testing this out in app preview or on a phone? If you’re using app preview or web apps, you’ll need to log in as a mobile worker (described here) in order for that property to be present (otherwise it uses data from your web user, which I don’t think will have that property set. You can also test this on a phone or tablet.

If you are already logged in as a mobile worker, the next step I’d suggest is to view that user’s restore as described here:
This is quite a technical process, but useful for debugging. The user data should be available in the registration element in that restore.