N
Novu•13mo ago
San

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
Pawan Jain
Pawan Jain•13mo ago
@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?
San
SanOP•13mo ago
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
Pawan Jain
Pawan Jain•13mo ago
Thanks for the update 🙂
San
SanOP•13mo ago
Is novu trigger api idempotent in nature?
Pawan Jain
Pawan Jain•13mo ago
yes, you can send custom transactionId if duplicate(or already processed) transactionId is sent, novu will not process that request
San
SanOP•13mo ago
So If I send custom transactionId again and again it will only trigger once but not twice?
Pawan Jain
Pawan Jain•13mo ago
if transactionId is same all times then first will be processed and rest other triggers will be skipped
San
SanOP•13mo ago
Can you please give me an example? On how to use that?
Pawan Jain
Pawan Jain•13mo ago
https://docs.novu.co/api-reference/events/trigger-event this api has transactionId field option
Pawan Jain
Pawan Jain•13mo ago
No description
San
SanOP•13mo ago
Got it thanks
Want results from more Discord servers?
Add your server