Age Calculator Brick Workaround

Abby Updated by Abby

We currently have an age calculator brick, however, it's made for V2, if you're using V3 you can make it work with the following workaround:

Import the brick

Open brick and go to the Javascript block

Remove the current code and add the following

let landbotScope = this;

function getAge(datepicker)
{var today = new Date(); var birthDate = new Date(datepicker); var age = today.getFullYear() - birthDate.getFullYear();var m = today.getMonth() -birthDate.getMonth(); if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { age--;}  

landbotScope.setCustomData({age: age})}getAge("@{datepicker}");

That's it!

How did we do?

How to link your Calendly account and prepare your agenda