When and how are metadata fields filled in odk-x?

In odk-x version, I would like to know when are the metadata fields such as _group_modify, _group_privileged, and _group_read_only are written to the database?

  • Are they written into database during data collection using odk-survey?
  • Are they later filled into the exported csv file and then uploaded again using table.init?
  • Could those fields be manipulated only programatically? Or is there any other way to read and write such field?

I also want to learn how to read, write and update those metadata field? Please kindly help.

The first place to start would be to look at the documentation that describes these fields.

The group fields are only useful if you create groups within your LDAP server and assign users to these groups. Thus, when the user verifies their identity in ODK-X Services, you will be able to get the groups they are affiliated with. Based on the groups that the user is assigned to, the _group_read_only, _group_modify, and _group_privileged fields will be used to filter the data they see on the device.

In terms of how the values for the _group fields are populated in a row, we typically use the odkTables.addRowWithSurvey API for this. I’ve included an example below.

var defaults = {};
defaults['_group_read_only'] = 'GROUP_NORTH';
defaults['_group_modify'] = 'GROUP_NORTH_EAST';
defaults['_group_privileged'] = 'GROUP_REGION_ADMIN';

odkTables.addRowWithSurvey(null, 'maintenance', 'maintenance', null, defaults);

The row created with the above API call would allow users in GROUP_NORTH to view this row. Users in GROUP_NORTH_EAST would be allowed to view and edit it. GROUP_REGION_ADMIN users, in addition to viewing and editing the row, would be able to delete the row and modify row-level access filter columns.

Thanks @clarice_larson. I will trying using the API you mentioned.