Why is my submission with a barcode id as the Entity id failing to update the appropriate Entity?

I am unable to update parameters of entities using a separate form. I have a dataset with each entity having an EAN13 barcode as a unique identifier. I am able to lookup data based on the sample ID and populate fields and calculations using this data, however when I submit the form I get a uuid invalid input, uuid expected to be valid version 4 uuid. I have looked at each entity and they all have valid version 4 uuids as entity IDs and there are no duplicate sample IDs, so I am unsure what the issue is. My form was set up as detailed in the tutorial and I had no issues in my test project before using the same process.

Submission error:

Data record form:
ODK Germination (1).xlsx (578.8 KB)

Any help would be much appreciated.

Welcome, @Luke_w!

Currently, ODK doesn't have a built-in concept of a "natural id" -- an id that is unique based on the specific domain that you're working in. That means that for now, all matching between Entities must be done using system ids. System ids are available through the name property because that makes them easy to use in selects. When using a natural id like your barcodes, you have to look up the corresponding name value for the identified Entity and this is the value you need to use for entity_id.

After your question of type barcode, you can add a question of type calculate that will be used to translate from a barcode to a system id.

Give it a name like system_id and then specify a calculation of instance('petri_samples')/root/item[sample_ID=${sample_barcode}]/name.

Then the really important thing is to change the entity_id on the entities tab to ${system_id}.

We know this feels quite manual currently! We've opted for maximum flexibility at first but there's definitely a usability tradeoff. We hope to eventually make it possible to specify that a certain property is a natural identifier to simplify some of this.

When you have a moment, we'd love to learn more about what you're working on in the introduction thread.

1 Like

Thanks @LN
Your response here has really been helpful.
However, in my case, even though I generated the system_id and changed the entity_id on the entities tab to ${system_id}, the related entity is still not updated.
Rather when I open the submission, I find the error below:


Any idea what could be wrong?

If you look at the submission table, do you see a value populated for the system_id column? If not, that suggests there's something wrong with the lookup expression. If so, maybe there's something not quite right about your entities sheet? If you can share the latest version of your form we can take a look at it together.

1 Like

Thank you, the issue is now resolved!

2 Likes

Thank you @LN!!!

All working perfectly now! Appreciate your help big time.

2 Likes