Contains function not working

Hi there!

I met the following problem, already report on ODK Forum but which appears being a KOBO Bug:

" What is the problem? Please be detailed.
I’m trying to use the contains() function but always get this answer when deploying it
Unexpected KoBoCAT error 400: {“detail”:"ODK Validate Errors:\norg.javarosa.core.log.WrappedException: Error evaluating field ‘drug_combin2’: The problem was located in calculate expression for ${drug_combin2}\nXPath evaluation: cannot handle function ‘contains’ =>

What ODK tool and version are you using? And on what device and operating system version?
Xls from on excel and Kobo tool box

What steps can we take to reproduce the problem?

Create a calculate field with the contains() function and try to deploy it

What you have you tried to fix the problem?
change the way of how te function is working, but dind’t find anything **

Thanks to take this into account :slight_smile:

The XPath contains() function does indeed work in ODK Collect and Enketo (ie Kobo previewer). You can verify this running this form with XLSForm Online, or previewing it in KoboToolbox:

contains.xls (5.5 KB)

However I dont know precisely when contains() was added into ODK javaRosa, nor when javaRosa was last updated in KoboCollect/KoboCAT. Which is to say it may not be supported yet in the version you are running…

In the mean time have you tried using selected() instead? It may suffice.


Thanks a lot !
Need to change the name of “constraint” variable to another one (row5) but it functions with the example on XLSForm you join me contains.xls (25 KB)

1 Like