How to Hide a Data Element for Certain Users in DHIS2 Tracker Program

Hello everyone,

I am currently working on a DHIS2 2.38 Tracker program and need to hide a specific data element for certain users. I want to ensure that only users with specific roles can view and interact with this data element, while others should not have access to it.

Could someone guide me on how to set up these permissions in DHIS2? Specifically, I am looking for detailed steps on how to configure sharing settings or any other method to restrict access to a data element based on user roles.

Thank you in advance for your assistance!

Best regards,

1 Like

Despite following the recommended steps to configure sharing settings, I am still unable to restrict access as needed. Here’s what I have done so far:

  1. I accessed the Tracker program and selected the data element I want to hide.
  2. I went to the sharing settings of the data element.
  3. I set the public access to “None.”
  4. I added the user roles that should have access to this data element with “Can View” permissions.
  5. I saved the changes and tested with different user accounts.

However, the data element is still visible to users who should not have access.

Could anyone provide more detailed steps or additional configurations that might be necessary to achieve this? Are there any specific user role settings or additional restrictions I might be missing?

Thank you in advance for your help!

Best regards,

Hi @elmoujarrade,

I have worked on something similar in the past. But it may not be inherently possible.

I think the permissions on the data element should work but it doesn’t work, you may still want to find a way around it.

if all these users belong to a particular org unit, then the steps below may be helpful. That way, you can hide the field when the seleced org unit is what the users belong to

Hi @Quoda
Thank you for your response and suggestion. Unfortunately, the method of using organization units to hide the field won’t work in my case because all the users belong to the same organization unit.

I need to hide a data element for certain users who share the same organization unit, so the visibility needs to be controlled based on user roles or attributes rather than organization units. If there are any other possible solutions or workarounds that could help achieve this, I would greatly appreciate your insights.

Best regards,

Hi,

You could create a user role and assign those specific users to that user role. With program rules you can check if the user has that user role, if its then you show the DE or otherwise you would hide it.

3 Likes

Yes, as said Daler just follow the simple steps:

  1. create a specific user role, without any permission inside. Get the id of this role
  2. Create a programs rule, where you will check d2:hasUserRole(‘user_role_id’)
  3. list all elements which you want to hide
2 Likes

Hi @Daler, @Ulanbek ,

I wanted to extend my heartfelt thanks to both of you for your invaluable help. Following your advice, I created a specific user role and used program rules to conditionally hide the data elements based on this role. The steps you provided were clear and effective.

  1. I created a new user role without any permissions and assigned it to the relevant users.
  2. I used the **d2:hasUserRole('user_role_id')** function in a program rule to check for this role and hide the data elements as needed.

This solution worked perfectly, and I am very happy with the results. Thank you again for your support and guidance!

Best regards,

1 Like

Thanks! Is there any way to do the same for aggregate data element?
I’ve edited sharing setting for a specific groupe to only have access to my data element. But in the dataset the other users can see the data element and add value, even they can’t save the edited value.

I want a way to hide the data element or make the field non editable like when we add restriction on a category option.
Thanks