# Program rule not working correctly on Android - Tracker Capture

**URL:** <https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663>\
**Category:** Mobile\
**Tags:** tracker, android\
**Created:** [6 February 2023 22:07 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663 "2023-02-06T22:07:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![minyoi](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/minyoi/32/44112_2.png) [@minyoi](https://community.dhis2.org/u/minyoi)\
**Post date:** [6 February 2023 22:07 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/1 "2023-02-06T22:07:58Z")

</div>

Hi,

I have setup a program rule to show error when a value is less than a previously entered value:  
i.e. #{nlc\_pop\_at\_risk\_REPORT} \< #{nlc\_cases\_REPORT}  
This works perfectly on the web but not on Android. It only works well when the values are less than 100. For example, it is evaluating 101 to be less than 88, but correctly evaluating 99 to be greater than 88.

---

<div class="post-metadata">

**Author:** ![jaime.bosque](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jaime.bosque/32/42220_2.png) [@jaime.bosque](https://community.dhis2.org/u/jaime.bosque)\
**Post date:** [7 February 2023 11:06 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/2 "2023-02-07T11:06:57Z")

</div>

Hello @minyoi. Could you please share the metadata of the program you are using or access to a testing server where we could check this? Or recreate the program in any of the play servers?  
Thanks

---

<div class="post-metadata">

**Author:** ![enrico](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/enrico/32/34018_2.png) [@enrico](https://community.dhis2.org/u/enrico)\
**Post date:** [8 February 2023 08:04 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/3 "2023-02-08T08:04:47Z")

</div>

Hi @minyoi, the issue that you are experiencing was fixed in [[DHIS2-13821] - Jira](https://dhis2.atlassian.net/browse/DHIS2-13821). Let us know which version of the software you are using, maybe an upgrade will solve the problem

---

<div class="post-metadata">

**Author:** ![minyoi](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/minyoi/32/44112_2.png) [@minyoi](https://community.dhis2.org/u/minyoi)\
**Post date:** [8 February 2023 09:34 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/4 "2023-02-08T09:34:03Z")

</div>

Thanks @jaime.bosque …  
Hi @enrico, i am currently using dhis2 version 2.36.6 and android capture version 2.7.1. I recently upgraded the android capture version

---

<div class="post-metadata">

**Author:** ![Markus](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@Markus](https://community.dhis2.org/u/Markus)\
**Post date:** [8 February 2023 10:08 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/5 "2023-02-08T10:08:16Z")

</div>

Hey @minyoi !  
What is the data type for the data elements behind the variables you used in the expression:

> #{nlc\_pop\_at\_risk\_REPORT}

and

> #{nlc\_cases\_REPORT}

For some reason it sounds like Android rule engine treats the values as text, and the web rule engine treats the same values as numeric - so to try to reproduce it might be relevant which data types is used.

Markus

---

<div class="post-metadata">

**Author:** ![minyoi](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/minyoi/32/44112_2.png) [@minyoi](https://community.dhis2.org/u/minyoi)\
**Post date:** [8 February 2023 14:07 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/6 "2023-02-08T14:07:36Z")

</div>

Hi @Markus ,  
They are both Positive or Zero Integer

---

<div class="post-metadata">

**Author:** ![Matthew\_Boddie](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/matthew_boddie/32/34043_2.png) [@Matthew\_Boddie](https://community.dhis2.org/u/Matthew_Boddie)\
**Post date:** [9 February 2023 20:43 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/7 "2023-02-09T20:43:07Z")

</div>

This is a continuous issue on all Android versions after 2.5.2. The fix that was presented to me was to turn the text into a number by adding a subtracting a number to it in the program rule. This doesn’t work for us simply because of not wanting to add the complexity to so many program rules that we have in our system, but perhaps it can work for you @minyoi !

@enrico this was indeed fixed in capture app, as noted [[DHIS2-13821] - Jira](https://dhis2.atlassian.net/browse/DHIS2-13821) but was never fixed in android.

cc @Markus

---

<div class="post-metadata">

**Author:** ![minyoi](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/minyoi/32/44112_2.png) [@minyoi](https://community.dhis2.org/u/minyoi)\
**Post date:** [9 February 2023 21:53 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/8 "2023-02-09T21:53:21Z")

</div>

Yes indeed @Matthew_Boddie … The fix works perfectly and is certainly good enough for our setup. Thanks, much appreciated.

---

<div class="post-metadata">

**Author:** ![Matthew\_Boddie](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/matthew_boddie/32/34043_2.png) [@Matthew\_Boddie](https://community.dhis2.org/u/Matthew_Boddie)\
**Post date:** [10 February 2023 16:29 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/9 "2023-02-10T16:29:41Z")

</div>

Great @minyoi ! Glad that worked for you.

@jaime.bosque @Markus I couldn’t actually find a Jira Ticket on this issue for Android Software, which surprised me. This is a quite significant road block for us–just checking that this is clear? Happy to create a ticket or whatever is needed if useful.

cc @Gassim

---

<div class="post-metadata">

**Author:** ![jaime.bosque](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jaime.bosque/32/42220_2.png) [@jaime.bosque](https://community.dhis2.org/u/jaime.bosque)\
**Post date:** [14 February 2023 08:12 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/10 "2023-02-14T08:12:33Z")

</div>

Hello, @Matthew_Boddie . We are investigating the issue and we will let you know. You can always create the JIRA if you want and we will update it there (as well as here to link it) or , otherwise, we will create ourselves 🙂

---

<div class="post-metadata">

**Author:** ![Matthew\_Boddie](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/matthew_boddie/32/34043_2.png) [@Matthew\_Boddie](https://community.dhis2.org/u/Matthew_Boddie)\
**Post date:** [14 February 2023 21:04 UTC](https://community.dhis2.org/t/program-rule-not-working-correctly-on-android-tracker-capture/51663/11 "2023-02-14T21:04:47Z")

</div>

Thanks @jaime.bosque ! I posted a quick version here:  
[https://dhis2.atlassian.net/browse/ANDROAPP-5212](https://dhis2.atlassian.net/browse/ANDROAPP-5212)
