I am using the CommCare export tool (https://confluence.dimagi.com/display/commcarepublic/CommCare+Data+Export+Tool) to export my case data. We need to also know the supervisor of the user that is submitting the data. The supervisors are defined in the location hierarchy.
Is it possible to use the export tool to either:
a) get a table or series of tables that includes mobile workers with their locations and parent locations
b) in the case/form export do some kind of lookup on the mobile worker that gets the location and supervisor info.
I'm thinking user cases may also be a possibility to help make this happen?
Best Answer
The export tool can't export users, groups or organisations (locations) but you could use a mapping table to lookup the location or supervisor info based on the user_id.
You could do this by adding a Mappings sheet to your export query that contains the lookup table.
Here is an example of what your query sheet might look like:![Query sheet](https://i.stack.imgur.com/SiCjq.png)
We've defined two fields, Location and Supervisor which both reference user_id. We've also added a Mappings sheet as follows:![Mapping sheet](https://i.stack.imgur.com/p4BZY.png)
For each user_id value we have mapped them to the Location and the Supervisor.
When the export is run it will do the lookups the final export will contain the mapped values.
To get the data for the Mappings sheet you can use the user export and organisations (locations) export from CommCare HQ.