OpenFn / unicef-cambodia

UNICEF Cambodia - Primero Interoperability
https://openfn.github.io/unicef-cambodia/
1 stars 2 forks source link

parseInt(location_current_village_code) returns `NaN` string value #31

Closed aleksa-krolls closed 4 years ago

aleksa-krolls commented 4 years ago

https://github.com/OpenFn/unicef-cambodia/blob/fae432ab97e3e596226dfadef8656f24d53080ae/jobs/f2-j2-upsertCasesToPrimero.js#L327-L330

To convert location village code, the parseInt().toString function I implemented is returning a NaN string when the value is null. Can you please modify so that it returns a blank value ''.

See this run and search for oscar_number 01E6AT3AEHWY668FTHT06EAB2K.

Data provided by Oscar (ON: 01E6AT3AEHWY668FTHT06EAB2K / extId: ) : {
  "global_id": "01E6AT3AEHWY668FTHT06EAB2K",
  "location_current_village_code": "",

Data provided to Primero `upsertCase`:  {
  "remote": true,
  "oscar_number": "01E6AT3AEHWY668FTHT06EAB2K",
  "case_id": null,
  "child": {
    "case_id": "",
    "oscar_number": "01E6AT3AEHWY668FTHT06EAB2K",
    "location_current": "NaN",