Program rule validation rule using d2:left does not recognize zero

Hi all,

I’m setting up a program rule that autocalculates a client code based on data entered in previous TEAs. This should be a 12 letter code as follows:

  • First two letters of first name (text)
  • First three letters of surname (text)
  • Two numbers of day of birth (integer)
  • Two numbers of Month of birth (option set)
  • First three letters of village of birth (text)

Expression:
d2:left(A{REA- First two letters of first name},2).toUpperCase() + “” + d2:left(A{REA- First three letters of surname},3).toUpperCase() + “” + d2:left(A{REA- Day of birth},2) + “” + d2:left(A{REA- Month of birth},2).toUpperCase() + “” + d2:left(A{REA- First three letters of village of birth},3).toUpperCase()

The code is working well EXCEPT for the day of birth field. The 12 letter code generates for all days 10-31 but only generates an 11 digit code for days 01-09. Essentially, it is not picking up the zero.

Any tips on how to resolve this?

Many thanks,

Monika

Hi all,

Just bumping this in case anyone has any tips or feedback!

Many thanks,

Monika

@Scott, could you have a look? :slight_smile:

1 Like

@Karoline Sorry I am not a program rule expert. I recommend @Markus @Enzo @YuryR or @mike

Yeah, sorry about that, was reading “validation rule” first and foremost, not program rule - I agree that @dhis2-tracker would be good team to have a look! :slight_smile:

1 Like