Access instance('commcaresession') from "Case List Search Callout"

Hey!

This is Milen from Simprints. I'm trying to pass the app version from CommCare to SimprintsID so we can better analyze issues. I have succeeded doing this from a callout inside of a case by adding an extra with value instance('commcaresession')/session/context/appversion. However, when I attempt to do the same from a "Case List" callout (i.e. before a case selection has been made) I get the following exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.commcare.dalvik/org.commcare.activities.EntitySelectActivity}: org.javarosa.xpath.XPathMissingInstanceException: The instance "commcaresession" in expression "instance(commcaresession)/session/context/appversion" used by "/" does not exist in the form. Please correct your form or application.

So, my question is it possible to access commcaresession from the Case List Search Callout?
If not, is there an alternative to access the app (or at least ccz) version from there?


Generally
"instance('commcaresession')/session/context/appversion " is available at Case List level of an application.

Can you confirm if this issue occurs only when appVersion Extras key is set to that instance expression and not otherwise?

Yes, I can confirm that deleting the key or changing its value to a hardcoded string fixes the crash.
I'm using CommCare v2.55.0, build 467579. Let me know if I can help with any further details.

@Milen_Marinov : Then it confirms that the value instance('commcaresession')/session/context/appversion is not available at Case List Search Callout. I think this will need an enhancement on the Case List Search Callout feature to have access to commcaresession data in the context.
I think it would be ideal to raise a ticket through 'Report an Issue' functionality of CommCare.

1 Like

Thanks! That's sad! I will raise a ticket but in the meantime (and for old versions) - would there be an alternative to access the ccz version in the Case List Search Callout?

@Milen_Marinov : I am not sure if this will work for you or not but may be save the appVersion on each case of case-type where you are plannnig to perform the app-callout for searching. You may be able to refer the case properties of case in this section of the CommCare. So you may just need to set appVersion to that case property.

Let me make sure I got you correct:
If I have a case type called "person" and the search callout has "person" set for case type, you are suggesting to add a case property appVersion to the "person" case type - is that correct?
If yes, then I am confused:

  1. How can I set this property on all instances of "person" to instance('commcaresession')/session/context/appversion?
  2. How would I access it in the search callout when (obviously) no case has been selected yet?

Or did I get your suggestion completely wrong?

I agree, that is not possible as your integration is searching for a case but not selecting a case. Unfortunely, the enhacement seems like the only option :expressionless:

I see. Thanks for the assistance!