# How to use enrolling org unit in program rule

**URL:** <https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847>\
**Category:** Support - Assistance technique\
**Created:** [22 January 2019 17:55 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847 "2019-01-22T17:55:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerard\_Bisama](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gerard_bisama/32/27281_2.png) [@Gerard\_Bisama](https://community.dhis2.org/u/Gerard_Bisama)\
**Post date:** [22 January 2019 17:55 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/1 "2019-01-22T17:55:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SDKAAA](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/sdkaaa/32/43219_2.png) [@SDKAAA](https://community.dhis2.org/u/SDKAAA)\
**Post date:** [23 January 2019 06:37 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/2 "2019-01-23T06:37:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gerard\_Bisama](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gerard_bisama/32/27281_2.png) [@Gerard\_Bisama](https://community.dhis2.org/u/Gerard_Bisama)\
**Post date:** [23 January 2019 10:42 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/3 "2019-01-23T10:42:38Z")

</div>

Thanks Bernard, it solves my problem

---

<div class="post-metadata">

**Author:** ![WaluQ](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/waluq/32/118_2.png) [@WaluQ](https://community.dhis2.org/u/WaluQ)\
**Post date:** [16 May 2022 12:38 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/4 "2022-05-16T12:38:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [16 May 2022 12:58 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/5 "2022-05-16T12:58:02Z")

</div>

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}~~.

> [@WaluQ](#):
>
> Is this created manually when adding OrgUnits (in the `Code` field) or it’s auto-generated by DHIS2?

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](https://play.dhis2.org/2.37.6/api/organisationUnits?fields=id,code,name)

Thanks!

---

<div class="post-metadata">

**Author:** ![WaluQ](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/waluq/32/118_2.png) [@WaluQ](https://community.dhis2.org/u/WaluQ)\
**Post date:** [19 May 2022 20:04 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/6 "2022-05-19T20:04:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [20 May 2022 04:40 UTC](https://community.dhis2.org/t/how-to-use-enrolling-org-unit-in-program-rule/34847/7 "2022-05-20T04:40:27Z")

</div>

Yes @WaluQ, I believe so! (:
