Skip to main content

Hi. We have a date of birth and age field in Pipedrive. We want to auto-compute the age based on the date of birth. I came across an article the might be solution using Formatter. Can someone share step by step guide? Ty

Hi @MagneticAA 

Good question.

Try this Zap action: Code - JavaScript

// Convert the birthdate string to a Date object
let birthdate = new Date(inputData.birthdate);

// Get the current date
const currentDate = new Date();

// Calculate the age
const age = currentDate.getFullYear() - birthdate.getFullYear() - (currentDate.getMonth() < birthdate.getMonth() || (currentDate.getMonth() === birthdate.getMonth() && currentDate.getDate() < birthdate.getDate()) ? 1 : 0);

output = {age, birthdate}];

 


Hi @Troy Tessalone Thank you. I’ll test it! 


Hi. @Troy Tessalone Seems to be working. But not reflecting in Pipedrive. Would appreciate any thoughts.

See below:
 

 


@MagneticAA 

You need to add a Step 3 to update the Person from Step 1.

 


Hi @Troy Tessalone Not sure which to set here. Can you please advise? Thank you so much. 

 



 

 


@MagneticAA 

The ID needs to be mapped from Step 1.

The screenshots shows the mapped dynamic variable is not a valid variable.

 


Hi @Troy Tessalone Apologies. I’m not really sure which field to choose or how to find the record from Step 1. Do you which specific field to find?
 

 


Hi there @MagneticAA,

I’m jumping in to see if I can help!

You will need the Person ID from the trigger, and map that as a custom value to the “Person” field in the Update Person step. Here’s what the Person ID data looks like:

470a31147b36fca16a4260c5b8516a4c.png
(view larger)

Additionally, it looks like you’re using an identical trigger (Updated Person) and action (Update Person) this might cause your Zap to loop infinitely. I suggest changing the trigger to the New Person trigger.

Hopefully, this helps! 😊


@MagneticAA 

Search for ID.

 


Thank you so much @Troy Tessalone It’s working now. 


Awesome! Glad to hear Troy was able to help you out @MagneticAA!

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 😊