Help filtering date that has a end date on it

HI all , hope you can help , i have the following transformer getting data out of an api call , unfortunately the api call is returning data that has epxired and i want to filter out

it relates to contact information so if we make a change to the contact , it ends the current record and creates a new one, i only want to show the records that are active

the transformer i'm using is

const data = {{FindContacts.data}}

// Initialize an empty array to hold final data
let finalData = ;
// Loop through each key in the data object
Object.keys(data).forEach(key => {

// Retrieve specific data points for each instance and assign to variables
let Lastname = data[key]["a:LastName"][0];
let Firstname = data[key]["a:FirstName"][0];
let Dob = data[key]["a:DateOfBirth"][0];
let Contactid = data[key]["a:ContactId"][0]
let effectivetodate =data[key]["EffectiveToDate"]

// Create a new object containing all relevant data points
let newObj = {
'Lastname': Lastname,
'Firstname': Firstname,
'Dob' : Dob,
'ContactId': Contactid,
'effectivetodate' : effectivetodate

  };

// Add new object to the finalData array
finalData.push(newObj);
});

// Log finalData to the console and return it
console.log(finalData);

the record i want to show looks like

image

any advice on how to best achieve this is most welcome.

Hello @northdevon,

If I understand you question you want to filter out entries with old dates right? If so, a simple if statement should do the trick:

if (!effectivetodate || effectivetodate[0]["$"]["i:nil"] === "true")

Just add this before creating the object so the entries with empty or null dates don't get added.

sorry cant seem to get hits working , would you be able to provide some more detail please

Hi @northdevon :wave:

Checking in to see are you still working on this?