How to assign a DataElement to a specific DataSet using API?

Someone who can help with the following challenge: “I can create a Data Element and can successfully associate it with a CategoryCombo but i can not find a way to add it to a specific DataSet. Can you please point me in the right direction on how to achieve this using the API? Thank you”

Hi @Breno, a category combination can be easily assigned to a data set through the maintenance app.

If you assign the category combination to a data set you will need to remember to assign the category options that are in that category combination to organizational units also. If you do not do this you will not get reporting rates for these datasets.

Understood, but how can this be done through APIs, when populating data from an upstream eLMIS, to avoid the need for manual configuration? We are looking to automate as much of the process as possible.

If I recall correctly you need to put the DataElement directly on the Section. This would be the visual representation more or less:

So just get the DataSet, get the Sections and add the DataElement there. Also, there was a bug (which I think is still present) that sometimes you will be seeing stuff via the API that cannot be undo straight away from the graphical interface. For example:

  1. If you remove the Data Element from the Data Set without removing it from the Section first the Data Element will still be present. So you need to remove it first from the Section and then from the Data Set
  2. If you add the Data Element twice to the Section (importing via the API two Data Elements with the same UID) you will see it only once in the graphical interface and will cause problems (i.e. Android will not work) to fix it you will have to go to the API to remove them.