I made a survey which works perfectly on the computer, but not on the phone. JavaRosa does not recognise the function ‘substring-before’. Can anyone suggest a way to solve this?

This particular function was only added recently (by yours truly) to javaRosa, so you’ll need to run a recent version of ODK Collect to use it. I don’t believe the current version of KoboCollect (circa 2018?) is recent enough.


Thanks! Indeed the version on playstore and the one I have is still the same from April 2018.

1 Like

FYI substring-before(), substring-after(), and translate() functions are in ODK Collect v1.19 and later.

The only possible workaround is if you know a priori the precise position of your delimiter (eg “XXX-YYY…” and the ‘-’ is always the 4th char) then you can use the existing substr() function instead.

1 Like

Well, this is not the case of course. So there is no function similar to excel find(substring, string) which could give you the number position of the delimiter?

Nope (which is why I ended up having to implement substring-before()… :slight_smile:

The only conceivable way you could do it is with a messy repeat group that iterates thru each character in the string looking for your delimiter, then feed it into substr(). But that would require the user to manually flip between each repeat iteration (even if they dont actually enter anything).

If you are desperate I might suggest running a newer ODK Collect in the mean time. Its compatible with Kobo, but obviously unsupported (KoboCollect is basically a Kobo-supported fork of ODK Collect). Perhaps @tinok knows when KoboCollect will likely be rev’d next to pickup these new Collect features?