getodk / xforms-spec

The XForms-derived specification used in the ODK ecosystem. If you are interested in building a tool that is compliant with the forms rendered by ODK tools, this is the place to start. ✨⚒✨
https://getodk.github.io/xforms-spec/
30 stars 26 forks source link

clarify when odk-instance-first-load is fired #250

Open MartijnR opened 4 years ago

MartijnR commented 4 years ago

Not immediately clear to me if this done after calculations or before (but may be overlooking).

lognaturel commented 4 years ago

Yes, that needs to be documented. It should be before. odk-new-repeat also behaves this way and this is explicitly documented. That makes sense, right? You want to base your initial computations on any default values that have been set, for example.

The current description is just "dispatched the first time an instance is loaded" which is actually pretty confusing because it sounds like it refers to primary vs secondary instances to me. Maybe "the first time that the primary instance for a specific record is loaded, before initial evaluation of calculates, constraints, etc"?

MartijnR commented 4 years ago

Thanks!

Yes, that would be consistent with odk-new-repeat, and that's what I assumed Collect is doing, and seems fine to me.

I think there are always use cases that have a problem with whatever we choose. The current one of a client is to 'calculate' a value from an external instance (e.g. with pulldata) and use that stored value in the dynamic default (and elsewhere in other calculations) But the solution to that problem is simple, they will have to put the pulldata part in the default expression directly and perhaps accept some duplication of the pulldata() expression if they plan to use it multiple times.

"the first time that the primary instance for a specific record is loaded, before initial evaluation of calculates, constraints, etc"?

Yes, that's sound good.