How to disable and enable specific data entry field in DHIS2

Dear DHIS2 family
How do we disable and enable data entry fields in DHI2? We have some data elements and indicators that we need to disable on the entry field side for a specific time and enable gain for a specific time frame. We want to manage our users so that they don’t enter incorrect data at the wrong time.

Hi @Shapr0019

Is this for the Data Entry app (aggregate data set,) Event program, or Tracker program? Could you please explain more about the use case to see if there are other possible solutions to approaching the same result?

Thank you!

@Gassim hope to find you well.
See the picture below, data entry appy . Is there way to disable user to enter data into a specific field or data elements in this case for example to disable data entry on field 25-59


/5-9 or to disable the whole data element for a certain period of time and enable later .

1 Like

Hi @Shapr0019

First of all, maybe you can create a feature request for this to be a feature in the new Data Entry app (Beta)?
From your post:

  1. Disable specific fields from certain user (user groups)
  2. Disable specific fields for a certain period

However, for now I can suggest some workarounds:

Using JavaScript and CSS in the custom data set design:

This is a bit complicated but here’s the scenario. If you or a developer who can create the script, it should be possible. For the input fields to be disabled, create a script that will disable them by default i.e. for each input field add a CSS class name and then run the script document.getElementsByClassName('CLASSNAME_HERE').disabled = true; and then since it’s not functional to use timing here, you find it helpful to create a password input which only certain users will know and if they enter the correct password then change ‘true’ to ‘false’ .

Using data set configuration settings

Using the dataset settings ‘Complete allowed only if validation passes’ & ’ Complete allowed only if compulsory fields are filled’, and then create a compulsory field with a validation of a specific number example 1.5956 [this will only stop users from unintentionally pressing complete]

Create the dataset into several separate data sets…

It helps a lot more when the use case is shared and this is ultimately how innovations are developed, so if you decide to create a feature request, maybe more info about the necessity for these settings and configurations (disabling input fields for certain users during certain periods of time)

Either a different approach based on best practices will be suggested or a feature could be requested.

Hope you find this helpful!

Thanks!

@Gassim thank you . Its not yet clear though . I still have a lot of work to be done to make it work .

1 Like

You’re welcome!

I recommend creating a feature request (disabling/enabling fields for certain users and for certain periods) for the new Aggregate Data Entry (Beta) app. If you would like to create a feature request please use this site: https://dhis2.atlassian.net/ (you will need to create an account if you don’t already have one.

Please share the link to the ticket here so others can find it and vote for the same feature.

Thank you!

@Gassim I got this solution where you to data set, manage section, manage grey fields. This where you disabled all the field that you don’t want to be entered. The functionality is working well when use DHIS 2 Demo - Sierra Leone platform while when I tried to use our DHIS2 same version is not working. I can be able to disable the field but when I go to the entry side the fields are still accepting the entries. What might be the issues, where should I configure or sort out.


Check the image for the demonstration in DHIS 2 Demo - Sierra Leone

1 Like

Great, thanks for sharing!

If you are using a superuser account this might be the case. Please try to use a user with lower authorities and check again.

If the issue is still the same even for non-superusers then would check if there areany errors showing up in the console or network tabs in the browser’s DevTools (F12)?

I think this setting is for all users, right? (And not for specific users? and period?)


@Gassim when you say use user with lower authorities. What lower authorities exactly. I am failing to get the solid solution . What else should i do and try

1 Like

@Shapr0019, thanks! What I mean is if you are a superuser, please test using a data entry role user. (here’s a reference from the docs about Managing User Roles, click here.)