Created
September 1, 2021 20:45
-
-
Save kale-bogdanovs/837bb1e1d65da9a2b4efffbfbb07041c to your computer and use it in GitHub Desktop.
Handle multiple records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
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