NEW For more powerful tools consider the new Zingtree CX Actions: Transformation Functions and Script Node instead.
Zingtree has built a handy webhook you can use to turn a person's birthdate into their age. You just need to add a new Webhook and install it into the node where you want the calculation to take place. Here's how to set it up:
Step 1:From theApps & Integrations menu, chooseMy Apps:
This page lists all of the Apps you have presently installed. You can edit, duplicate, or delete any of them from the list. In the Uses column, you can easily see how many trees an individual App is being used. Click on the number in the Uses column to see which trees are using that App.
Adding a new App
Click the Install App button. You'll then see this screen:
Choose the Webhook button to add a new Webhook. You'll see these options.
- Go to Apps & Integrations from the top menu.
- Click on Add Webhook.
- Give the Webhook a name (like "date to age"), and enter this for the webhook URL:
https://zingtree.com/apps/webhook/lib/date-to-age.php
The end result looks like this:
Step 2: Call the webhook from your tree
If you have a variable called date, you can create a new variable named age as follows:
- Open your tree, and edit the node where you want the age calculated.
- Under the Apps & Webhooks section, click Add App.
- Pick the Webhook you added previously (Date to Age, for example).
- In the Message Data area, enter something like this:
&result=age&date=#date#
In the above example, the variable date is used to create a new variable called age.
Your edits should look something like this:
Now just use #age# anywhere you want to show the person's age based upon their birthday.
Important Note: This webhook is set to work with dates that are formatted as yy-mm-dd. You may need to update your tree's date picker format. You can do this in the tree's Settings > Language section like this: