XPath external instance lookup working in Enketo (Web) but returning blank in KoboCollect (Android)

Hi everyone,

I am experiencing an issue where a complex XPath calculation works perfectly on Enketo web forms but fails to retrieve/calculate any values when run on the KoboCollect Android app.
Following is the XPath formula i am using
instance(‘org’)/root/data[(normalize-space(${sp_business_id}) != ‘’ and bus_uuid = ${sp_business_id}) or (normalize-space(${spr_personbus_uuid}) != ‘’ and bus_uuid = ${spr_personbus_uuid}) or (normalize-space(${sp_busrole_id}) != ‘’ and bus_uuid = ${sp_busrole_id}) or (normalize-space(${sp_busci_id}) != ‘’ and bus_uuid = ${sp_busci_id})]/ntn
It works properly and fetch the value from “org” external file in enketo web form but does not fetch value in kobo collect android app

This is my xls form https://docs.google.com/spreadsheets/d/1PeyJkRanI7TXqz67uB-MbHDcslvi0Aj4JzDS0dhGNdg/edit?usp=sharing.

@jurrefws
Thanks for sharing this. We’ll review it shortly. I’ve requested access to the Google Sheets file so I can take a closer look and provide more detailed assistance.

Is it possible - given your specific dataset - that the above filter might return multiple matches for some bus_uuid?

The Enketo vs Collect (javarosa) XPath engines behave slightly differently when this happens, so if there is the potential for more than one match, you have to fiddle with the XPath expression a bit more to only return the first.

Since the lookup works in Enketo but returns blank in KoboCollect, I’d first compare the KoboCollect version and make sure the form has been re-downloaded after the latest changes. Older cached forms or differences in XPath support between Enketo and KoboCollect can sometimes cause this kind of behavior. It would also help to verify that the external instance is being downloaded correctly and that the lookup key matches exactly (including case and any hidden spaces). Sharing the XPath expression and the KoboCollect version would make it much easier to identify the root cause.