Date Format in Notification Template Using Handle bars
Hello
Is it possible to format date using the timestamp?
Example:
input:
employee = "Test User"
startDate = 1679079540634
endDate = 1679079540800
Notification Template => {{employee}} has submitted a leave request for {{startDate}} to {{endDate}}
Expected output:
Test User has submitted a leave request for Oct 1, 2023 to Oct 10, 2023
I did use inbuilt helper named
dateFormat
I tried to do this {{employee}} has submitted a leave request for {{dateFormat startDate 'MMM Do YYYY'}} to {{dateFormat endDate 'MMM Do YYYY'}}
Output I got was
Test User has submitted a leave request for 1679079540634 to 1679079540800
So dateFormat will not work if startDate or endDate is in timestamp integer?12 Replies
@San
startDate
and endDate
variables should be a valid date as per javascript specification
Reference:-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse
@San
Did you try with valid date format?We are making use of unix time format which is of type int
So I had to manually change the date format in the code using some libraries instead of novu handling it
Because novu cannot able to work with int types @Pawan Jain
Thanks for the update 🙂
Is novu trigger api idempotent in nature?
yes, you can send custom transactionId
if duplicate(or already processed) transactionId is sent, novu will not process that request
So If I send custom transactionId again and again it will only trigger once but not twice?
if transactionId is same all times
then first will be processed and rest other triggers will be skipped
Can you please give me an example?
On how to use that?
https://docs.novu.co/api-reference/events/trigger-event
this api has transactionId field option
Got it thanks