Is it possible to use events in an XLSForm?

I would like to use the odk-instance-first-load and the (apparently undocumented?) xforms-revalidate event to set a value when a form is opened and saved respectively. But it looks like I can't use those events in an XLSForm - is that correct?

This is a bit of a pain because I'm hoping to use Kobo Toolbox on this particular project, mainly because of the table view and the Enketo integration, but it seems like it's not possible to upload a raw XForm to Kobo Toolbox server.

1 Like

Actually, @martijnr: is it possible to use events with Enketo? Does Enketo know about the xforms-revalidate event?

It is not currently possible to directly use events in an XLSForm. Dynamic default support will make it possible to use odk-instance-first-load narrowly to set certain fields' values exactly once on load. Unfortunately, I don't know when this will be implemented.

If you don't need the value to be changed by the user, you can use once(your expression). In fact, you can use this to approximate a dynamic default, it just won't allow users to clear it.

I don't know of a reliable way to do something on form save. I don't believe any client has broad support for xforms-revalidate, hence why it's not documented. This would be a good event to add (but I'd prefer to close out some of the in-flight improvements rather than starting new things).

2 Likes

No, no events support in Enketo yet unfortunately. We were hoping to get this work done under a current grant, but it's not yet clear if we'll be able to with the remaining budget. It's one of the major projects on our roadmap (XForms Actions) to become fully spec-compliant (the other one is "dynamic readonly", but is a lower priority).

xforms-revalidate is not planned to be part of this, but we can open a discussion about adding this to the spec.

2 Likes

Maybe a(nother?) side discussion for the convening? I'm starting to look at implementing events/actions too, and I'm sure there's some 'gotchas' lurking... So any forewarning I can get from others perhaps a little bit further along with working thru the details. I'd certainly be up for a chat (over beer naturally)! :slight_smile:

2 Likes