Triggering custom forms after Data import from the API

The situation is :
A custom form for data entry in dataset exist with notably custom functions triggered when the event’s status is completed after validation. I would want to push a bunch of the Data Element collected through the API instead of the forms but still need to trigger those functions without having to go back to the Data Entry and visit all the forms.

Is there a way to trigger the validation + completeness of data entry custom forms that would make those functions runs through the API after the data elements import by any chance ?

Hi @ekhalil

Welcome back to the community!

Where are the custom functions? Are they in the HTML code of the custom form?

If you are sending values using the API, why are the custom functions still needed? The validation rules should apply when using the API as well.

The status code will be 201 Created if the data value was successfully saved or updated, or 409 Conflict if there was a validation error. (source)

Thanks!

1 Like

Hey :slight_smile: Yes, the custom functions are in the HTML code of the custom form and populate other DE from the data entry once validated. It is there for historic reasons and for the moment, I need both to coexist as the custom functions have not been implemented elsewhere yet (long story short) and I can’t populate those values form the API yet (or maybe at all).

AFAIK I understand your answer, when the data are sent via the API, it will still trigger the validation but probably not the custom functions in the HTML of the form?

The current workflow is:

  1. Fill the form of some specific DE
  2. Form is completed, custom functions in the HTML push other data values to a bunch of other DE

Not sure 2. is still the case going through the API.

Thanks

1 Like

Would it be possible to run these functions before sending the request? How are the API requests being sent?

1 Like

Currently, the custom functions are not ported to the script of batch upload. Could be in the future but they require previous data from the DHIS2 and will introduce a lot of back an forth. On the how, it is just a CSV going through a Python script pushing data through the API DataValueSets.

Thanks @ekhalil!

If the functions are in the code of custom forms then there needs a way for the API to access these functions, but configuring that seems more complicated than moving/copying those functions to be used at the API level rather than custom form.

Unfortunately, there isn’t an out of box solution for this case at the moment. Maybe if you share more about the use case, we could get more insights from other community experts and software team.

Thanks!

1 Like