Program indicator 2 conditions inside d2:condition() is giving an error

Hello everyone,
I am having a problem with the following program indicator expression:

d2:condition('d2:hasValue(A{HjnUuXNhHNS})==Yes) && d2:yearsBetween(A{b6DkisKMfJM}, V{current_date})<18', 'Watch Out', 'Clear to go')

The idea is if a Yes/No field has a value of Yes and the age of the individual is less than 18 years, to display a message, else another message.

The program indicator box is displaying:

Expression is not valid

I tried to add a missing ) at the end but still no success.

1 Like

Hi there!
Which version of DHIS2 are you running?

What is your end objective? Do you want to show information to the user entering data into the tracker, or make a report? If you just want to show info to the user - you might want to look into wether what you need is a program rule instead of a program indicator. With a program rule action of type “Display text” you can display infomation to the user entering data.
I would make a program rule that has the expression:
A{programRuleVariable for HjnUuXNhHNS} == ‘Yes’ && d2:yearsBetween(A{b6DkisKMfJM}, V{current_date}) < 18
And a program rule action of type “display text” displaying “Watch out” in the feedback or indicator widget(this is configured for the action).

Markus

1 Like