XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
75 stars 133 forks source link

Entity update forms currently must have the entity list attached #670

Closed lognaturel closed 5 months ago

lognaturel commented 6 months ago

Problem description

When an XLSForm specifies an entity update, an expression to get the existing entity's baseVersion is generated by pyxform. This expression reads from the entity list that the update targets, assuming that it will always be attached. However, there are useful forms to write that could update an entity without having the entity list attached. In particular, when using barcode ids offline to identify entities, there may not be any need to query the entity list.

The issue stems from Validate because JavaRosa specifically detects instance calls on instance names that aren't defined:

Error: ODK Validate Errors:
>> Something broke the parser. See above for a hint.
Error evaluating field 'baseVersion' (${meta}[1]/entity[1]/@baseVersion): The problem was located in Calculate expression for ${entity}/@baseVersion
XPath evaluation: Instance referenced by instance(participants)/root/item/__version does not exist
Caused by: org.javarosa.xpath.XPathMissingInstanceException: The problem was located in Calculate expression for ${entity}/@baseVersion
XPath evaluation: Instance referenced by instance(participants)/root/item/__version does not exist

Steps to reproduce the problem

Try to convert a form like https://docs.google.com/spreadsheets/d/1ALphkUqVgXGBV8jmCx0wohHDXknH1q3BHFQOj16IuA4/edit#gid=1068911091

Expected behavior

Some ideas for what we could do when the entity list isn't attached:

Other information

This kind of form is only practical if the barcodes are created from entities that are already registered. Maybe it's not a hugely useful/common scenario so we could wait until it comes up to address it. It may become more practical once bulk upload is more approachable.

lognaturel commented 5 months ago

Closing for now since there isn't an obvious action to take.