Add a custom Javascript form to the Data Entry App

Can I add form to the data entry form? If so, any documentation on the process.

Hello @jetisco4u

I advise you to take DHIS2 Fundamentals lessons . You will learn a lot of thing about DHIS2

Best regards
didate

1 Like

@didate thanks for the suggestion. I think the instruction in that lesson focus more on users rather than developers.

1 Like

@jetisco4u form more developer instruction can read on this page Prerequisites and initial setup | DHIS2 Developer Portal

1 Like

@IErnesto thanks for the suggestion. I have read everything on the that developer guide page which is why I am trying to develop an app to address our specific case. In the meantime, I wanted to know if and how I can add a custom Javascript form to the Data Entry App.

@jetisco4u ,

You can right click on the dataset you want to have custom form in maintenance app and click on “Design data entry form”.

Thanks,
Rithvik

1 Like

@rithvik I did try that before and design a custom form. I checked the data entry form and it didn’t appear. I thought after design, the form will appear automatically in the data entry form.

Hi @jetisco4u,

Yes, the form is supposed to appear. Please share as much info as possible on how to reproduce this on play.dhis2.org. If you have access to the logs please share the Catalina.out log (without the sensitive info).

Thank you!

On play.dhis2.org I follow the following steps.

  1. Created 2 data elements record.
  2. Create a Data element group and assign the two
  3. Assign the Data element group to an existing Data element group set
  4. Create a data set and assign the two data elements
  5. Right click the data set to create a data entry form
  6. Create the data entry form with a table with the data elements.
  7. Check the data entry app to test if the form will appear.

But I didn’t see the form among the list of forms.

As an alternative, if I want to design a custom form with a React app, which api will I use to save the response value in the database and what table will the value be saved?

The data entry app presents the form for a dataset. To fill the form for a dataset:

  1. Open the data entry app
  2. Select an organization unit assigned to the dataset
  3. Select the dataset (at this point the form should show up if everything else is fine)
  4. Select a period you want to enter data for
    Fill the form and complete
1 Like

@jetisco4u you can use api/33/dataValueSets endpoint.

Here is full docs :

@jetisco4u ,

Please clear cache using the “Browser cache cleaner” app and then go to data entry app. Any change made to datasets will only be reflected after cleaning the cache.

Thanks,
Rithvik

2 Likes

@didate Thanks you for the direction. Please I want to know, the api you pointed to seems to be using version 33. If I have version 38 instance running does it matter?

It is possible to add custom JavaScript to the dataset using ‘design data entry form’ so I still recommend you give the built-in feature a try. Here’s a tip to why the form doesn’t seem to appear:

Is there a reason why the form didn’t appear? Did you assign it to an Org Unit? And is the sharing settings for the dataset ‘Can Capture and View’ for the user you are using?

If yes then please clear the browser cache. The steps are correct but maybe missing some configuration steps.

Thank you!

ok. I will give it a try for the aggregate form I am working on. But for the other program, I will have to build a custom form that is an hybrid of aggregate and event. I am working on it.

1 Like