Skip to content

Instantly share code, notes, and snippets.

@kale-bogdanovs
Created September 1, 2021 20:45
Show Gist options
  • Save kale-bogdanovs/837bb1e1d65da9a2b4efffbfbb07041c to your computer and use it in GitHub Desktop.
Save kale-bogdanovs/837bb1e1d65da9a2b4efffbfbb07041c to your computer and use it in GitHub Desktop.
Handle multiple records
//...
const state = ad["Country_Region_Reference_ISO_3166-2_Code"]
const zip = ad.Postal_Code
const last_modified = new Date(ad.Last_Modified).getTime()
const home_address_last_modified = row.home_address_last_modified || 0
const work_address_last_modified = row.work_address_last_modified || 0
ad.Usage_Data.forEach(ud => {
ud.Type_Data.forEach(td => {
if (td.Type_Reference_Communication_Usage_Type_ID === "HOME" && home_address_last_modified < last_modified) {
row.home_address_street_address_line_1 = street_address_line_1
row.home_address_street_address_line_2 = street_address_line_2
row.home_address_city = city
row.home_address_state = state
row.home_address_zip = zip
row.home_address_last_modified = last_modified
}
//...
})
})
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment