Using the character "," breaks things

d2:condition("#{JpYILS81RQm.jPURrrbMqOt} == ‘some text with a , character’", 10000, 0)
the above example put as an expression in an indicator fires errors

steps to reproduce:

  • create an option set with the one of the options contains the character “,” in it in its code
  • create a tracker program that uses the above option set for one of the data elements
  • enter some values in the tracker capture of the program
  • update the resources table
  • create a program indicator with expression to check if the data element matches one of the option set options that contains the character “,”
  • add the new indicator to an event report
  • you would get an errors similar to:

java.lang.IllegalArgumentException: Illegal arguments, expected 3 arguments: condition, true-value, false-value

this error is probably a Java related error but there should be a way to circumvent it from code side.

from user’s side, the way to circumvent it is not to use option sets with the character “,”

JIRA issue added:


There are a number of special characters that could cause problems in specific circumstances, either due to lack of encapsulation in the code or because the character has a special purpose in certain software systems (not necessarily DHIS2 - could be HTML, or when importing data from DHIS2 into other systems).

So a general recommendation is to avoid using special characters in meta-data names and meta-data codes - as far as possible, stick to alphanumeric characters and under-scores which generally is safe (there is no real need to use special characters in things like option values, orgunit names, data element and indicator names, etc).

There are other common data capturing mistakes that frequently causes problems, like capturing of double spaces or incorrect casing - so if e.g. a name as been captured as “Donald J” with a double space, searching for “Donald J” won’t result in a match.

Beyond adopting good and consistent naming conventions for meta-data, you can search for and fix common capturing errors by running daily scripts (e.g.
“UPDATE trackedentityattributevalue
SET value = REPLACE(value, ’ ', ’ ')
WHERE value like ‘% %’;”
is an example: it will replace all text values with double spaces with a single space (obviously, you would only use this if you are sure that double spaces are always a capturing mistake).