i2group / analyze-connect-node-sdk

Develop connectors that bring data from external sources into i2 Analyze by using the i2 Connect Node SDK. The SDK is comprised of documentation, tools, and sample code.
https://i2group.github.io/analyze-connect-node-sdk/
MIT License
3 stars 3 forks source link

setProperties date field #8

Closed stvdo closed 12 months ago

stvdo commented 1 year ago

Good afternoon,

I try to add a DOB to a person. But I am struggling to get it in the WriteableDate format. Please can you advise me what to do to get it working?

The DOB format in the source: 8/16/1965

The code I have at the moment

_console.log('DOB', datum.date_of_birth); console.log('DateTime', Date.now()); const dob = datum.date_of_birth ? new Date(Number(datum.date_of_birth.split("/")[2]), Number(datum.date_of_birth.split("/")[1]), Number(datum.date_of_birth.split("/")[0])) : undefined;

entity.setProperties({ 'First (Given) Name': datum.first_name, 'Family Name': datum.last_name, 'Gender': datum.gender ? datum.gender : '', 'Place of Birth': datum.place_of_birth ? datum.place_ofbirth : '', // TODO: DOB gives an error 'Date of Birth': dob ? dob : undefined, });

And the error message. image

Ralph-Klaassen-i2 commented 12 months ago

There are some helper functions available in the data namespace that you might like to explore. Using your example:

import { data } from "@i2analyze/i2connect"; // your parsing code here entity.setProperties({ 'Date of Birth': data.createLocalDateTime( dob ) });

stvdo commented 12 months ago

Thanks again Ralph!