How to use enrolling org unit in program rule

Hi everyone,

I want to use enrolling org unit to define program rule. I have a field “List of Partners” and I want to fill it with values based on the org unit when the entity is enrolled. I am using program rule and program rule variable, How can I get the enrolling org unit in the program rule variable.

Thanks

2 Likes

The current org unit is available in the variable V{orgunit_code} So you can use this in your program rule.

I was also trying to find the list of other variables to publish here as a reference; maybe someone can help with that?
Best,
B.

2 Likes

Thanks Bernard, it solves my problem

2 Likes

What value is saved in the V{orgunit_code} and how do I get it? Is this created manually when adding OrgUnits (in the Code field) or it’s auto-generated by DHIS2?

1 Like

Hi @WaluQ,
@SDKAAA you’re free to add to this please but I’d like to add to @WaluQ that the expression V{orgunit_code} in the program rule will evaluate to the orgunit code so you don’t need to change it to V{OU_651071} .

When creating an OU, you have the option to add a CODE to it and if you don’t it won’t have a CODE. If you’d like to see how many Organisation Units in your system already have a code, you can try:
instance-uRL/api/organisationUnits?fields=id,code,name

Thanks!

1 Like

Alright, so if I got you correctly, the V{orgunit_code} will evaluate to whatever code I set in the OU code field at creation yes?

1 Like

Yes @WaluQ, I believe so! (:

1 Like