Inserting data into tracker using API in Form Sections

Hi Support,

So, I have a form like the attached image:

In my events object I have something like:

`“events”: [
{
“program”:program,
“orgUnit”:organisation_unit,
“eventDate”:“2024-03-31”,
“status”:status,
“storedBy”:“Sakhile”,
“programStage”:program_stage,
“dataValues”: [
{
{

                                "dataElement": "UAM5t0BxTss",
                                "value": completed_social_assets_10_14,
                                
                            },
                            {
                                
                                "dataElement": "e5fbIqTOPas",
                                "value": social_assets_10_14_started,
                                
                            },
                         
                            {
                                
                                "dataElement": "SRbhxVprbtD",
                                "value": social_asset_10_14_completion_date,
                                
                            },
                            {
                                
                                "dataElement": "SFKVWLrUZhg",
                                "value": completed_social_assets_15_19,
                                
                            },
                            {
                                
                                "dataElement": "wWDHoDYaGRR",
                                "value": social_assets_15_19_started,
                                
                            },
                            {
                                
                                "dataElement": "IQVewpHNyYS",
                                "value": social_assets_15_19_completion_date,
                                
                            },
                            {
                                
                                "dataElement": "nxVLtHPAlwt",
                                "value": completed_hiv_violence_prevention_10_14,
                                
                            },
                            {
                                
                                "dataElement": "CiCcBB9LP4N",
                                "value": hiv_violence_prevention_10_14_started,
                                
                            },
                            {
                                
                                "dataElement": "dUrapxKeEoG",
                                "value": hiv_violence_prevention_10_14_completion_date,
                                
                            }, 
                            {
                                
                                "dataElement": "OGFW9TkjI6b",
                                "value": completed_hiv_violence_prevention_15_19,
                                
                            },
                            {
                                
                                "dataElement": "PMJdXlVHiop",
                                "value": hiv_violence_prevention_15_19_started,
                                
                            },
                            {
                                
                                "dataElement": "nia2vPpqSZR",
                                "value": hiv_violence_prevention_15_19_completion_date,
                                
                            }, 
                            {
                                
                                "dataElement": "rJNIWkWfw2f",
                                "value": completed_hiv_violence_prevention_20_29,
                                
                            },
                            {
                                
                                "dataElement": "uvyfVmncrFk",
                                "value": hiv_violence_prevention_20_29_started,
                                
                            },
                            {
                                
                                "dataElement": "XVjRLRFxJbg",
                                "value": hiv_violence_prevention_20_29_completion_date,
                                
                            },
                        }
                    ]
                }, 
            ]
        }
   ]` 

In this code a programstage will not be created until I remove any data element that has to do with HIV Violence Prevention such that Social Asset Building is left alone. As in attached image these fields are divided into different sections, but I can’t find code in the DHIS2 documentation related to how to insert these values in form sections using the tracker api. Iam using DHIS2 version 2.39.3.1

Hi @1c699b409a68f19fba95

In this code a programstage will not be created until I remove any data element that has to do with HIV Violence Prevention such that Social Asset Building is left alone. As in attached image these fields are divided into different sections, but I can’t find code in the DHIS2 documentation related to how to insert these values in form sections using the tracker api. Iam using DHIS2 version 2.39.3.1

First of all, the purpose of sections is just for the UI, to better present data element as we want. Sections are not used when data are saved in the database.

Secondly, your json doesn’t seem to be correct, you have to put values between quotes.

Thirdly, are you sure that your values are correct ? For exemple does the Option Set of the the data element UAM5t0BxTss contain the value “completed_social_assets_10_14” ?

2 Likes

Hi Thank you those value are variables declared earlier in the code but I didn’t share that part I only shared the events part of the Json object so they can’t be in quotes, ok thank you I will have to remove the section then.