How to create entity attribute with generated value based on others elements

Hi everyone,

I am using tracker and I want to create a entity attribute with generated value that depending on other attributes values like :

  • code of the orgunit assigned to program

  • value of the field sex

  • followed by random number of 4 digit.

Each of them separated with “-”.

Do some one have an idea on how to achieve this?



Gérard Bisama

1 Like


You can use Text Pattern

Good luck!


Em Le Hong
DHIS2 Implementation| **HISP Vietnam ** | Skype:

1 Like

HI Gerard

Yes, this is possible with Text Pattern as mentioned previously.

One thing I would like to point out is that you create this all in the TE attribute. Therefore, create an attribute (e.g. Unique ID) and then select “Automatically generate”.

In the pattern, you can then enter the TextPattern that you require. Please note that to create a string, you separate with - and not with +. This is an example I created:


The “-” creates the dashes between the various variables, while the - separates the variables.

The number of dots and hashes in the OU code and Sequential relate to the number of items shown.

I hope this helps.

Kind regards,



Terence Scott

Global Alliance for Rabies Control (GARC)

Pan-African Rabies Control Network (PARACON) Steering Committee

Skype: tpscott1987


Thanks everyone for your response. I think the text pattern is option I prefer since it is quite clear and simple to configure. However I have this error when I want to register a new TE after adding a text pattern to the identifier attribute.

Error: Code is not implemented. I am using the version 2.27 is it due to that?


Le mer. 14 nov. 2018 à 10:46, Terence Scott a écrit :


Gérard Bisama

1 Like

Hi @Gerard_Bisama

This may be due to the fact that you have not attributed a Code to the thing that the pattern refers. E.g. if you have included the name of an Org unit into the pattern (as I did in my example above), then the OU needs to have a code attributed to it and that code needs to match what you have described in the pattern. In my example again, I used: “ORG_UNIT_CODE(…)” - this means that the OU will need a 3 letter code to refer as I have used 3 periods to signify the code.

I hope that this makes sense.

1 Like

exactly this is what i want to have WBG-WAU-JTH-10001 Where WBG is the Abbreviation of the State and WAU for the County and JTH is for the facility and follow by the number which will increment it self automatic whenever there’s a new enrollment.
Secondly I will need to learn the skip logic in dhis2.
and if you have pdf tutorial or video share it with me, because the previous link that you have share it not that easy to understand.
Best Regards

Dear Terence, I hope your doing well,
If you have a video tutorial or pdf Tutorial please share it with us because i tried to implement what you have said and I couldn’t implemented well.
Best Regards