Job to automatically upsert Tracked Entity Instances in DHIS2 returning undefined values

I’m trying to upload CSV data to DHIS2 to update Tracked Entity Instances. I’m using the upsertTEI(...) helper function from the OpenFn DHIS2 adaptor to upsert TEIs via a unique identifier (check if existing, update/insert accordingly).

    'SgQW3vpnhuL', //unique custom attribute in dhis2
      trackedEntityType: 'bsDL4dvl2ni',
      orgUnit: dataValue('OrgUnit'),
      attributes: [
          attribute: 'SgQW3vpnhuL',
          value: dataValue('SgQW3vpnhuL'),
          attribute: 'MxQPuS9G7hh',
          value: dataValue('MxQPuS9G7hh'),
    { strict: false }

When I run this job, all values return undefined.

Checking if a record exists that matches this filter: e[32mattribute{ id: SgQW3vpnhuL, value: undefined }e[0m ...
URLSearchParams { 'ou' => 'undefined', 'filter' => 'SgQW3vpnhuL:EQ:undefined' }
Usinge[33m lateste[0m version of DHIS2 api.

@chaiwa any ideas? Am I maybe missing something in my job expression? I

@aleksa-krolls It seems dataValue is not resolving correctly. Would you also share the sample state?

@chaiwa sure! Here’s the Message body for a CSV row I’m trying to upload to update a TEI’s Geographical Scope (custom attribute)…

  "csvData": [
      "MxQPuS9G7hh": "Regional",
      "OrgUnit": "xcs1ZRVThAV",
      "SgQW3vpnhuL": "005899TGO"
      "MxQPuS9G7hh": "National",
      "OrgUnit": "ijEoEQbfYXO",
      "SgQW3vpnhuL": "005532TST"

@aleksa-krolls What happens if you set dataValue as dataValue(csvData[state.index]['OrgUnit'])?

@aleksa-krolls Or simply csvData[state.index]['OrgUnit'], considering how each works.

Hey @aleksa-krolls , @chaiwa , I know that language-dhis2#v2.0.4 has now been released to; does this solve the issue?

@taylordowns2000 @chaiwa I’m not sure. There is nothing showing in the OpenFn logs, but the run is successful. How can I see the DHIS2 import summary? See example run:

It looks like language-dhis2 does not error out on empty arrays, which can be confusing but is important for longer, chained job expression. In this case, since the array provided for upsertTEI was empty and no other operations were performed, the run finished in something like 300ms! Given array items in there, you’ll see the expected logs.