Webhook emailed date issue

3030
7
Jump to solution
07-19-2018 08:33 AM
KassandraRodriguez
Occasional Contributor

I have created a webhook with Microsoft flow to send an email out when the survey is submitted but the date in the email returns as a long string of numbers ex: 

 I have it set up as a date type question in survey123 and it looks like this within the webhook:

I'm not sure what I'm doing wrong and help on this is much appreciated

1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Hi. You can use the addseconds function as follows.

addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['mydate'],1000) , 'yyyy-MM-dd')

For context, Survey123 date and time objects are expressed in UNIX time. UNIX time is the number of seconds elapsed since Jan 1 1970. With addseconds, you can get back a human friendly date and or time string.

This and some other tips on Microsoft Flow available at: https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... 

View solution in original post

7 Replies
ChristopherMatechik
New Contributor III

It looks like the date is being exported in EPOCH time. See this link for an explanation of different date/time formats. I'm not sure how dates are handled when they are sent from Survey123 to other web apps but here is what I would try.

Create a calculated field in your survey (it should be hidden by default). In the calculate column try:

format-date(${[name of your date field]},'%m/%d/%Y')

This should create a new field with the date expressed as a string in the format MM/DD/YYYY. You should be able to reference this in your email webhook.

Note - you can customize the format however you need. The different options are listed on the link.

KassandraRodriguez
Occasional Contributor

Thanks Chris so with doing what you recommended you can't immediately see your attribute as an option in the Microsoft Webhook dynamic content list because it's hidden in your survey. So going onto expression I was able to just type it out as:

triggerBody()?['feature']?['attributes']?['Date']  and returned 

Thanks a bunch!

0 Kudos
IsmaelChivite
Esri Notable Contributor

Hi. You can use the addseconds function as follows.

addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['mydate'],1000) , 'yyyy-MM-dd')

For context, Survey123 date and time objects are expressed in UNIX time. UNIX time is the number of seconds elapsed since Jan 1 1970. With addseconds, you can get back a human friendly date and or time string.

This and some other tips on Microsoft Flow available at: https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... 

by Anonymous User
Not applicable

If anyone wants to convert UNIX time into a readable date string using Integromat - use a similar expression to what's shown below.

{{formatDate(parseDate(substring(1.feature.attributes.dateTimeFieldName;0;10); "X"); "YYYY-MM-DD hh:mm A")}}

by Anonymous User
Not applicable

Can we use this in the Source File > Map? To rename the file? or is there another process

Thank you!!

0 Kudos
ColtonPhillips
New Contributor III

Thank you Anonymous User, you are true hero!

0 Kudos
ErinAas3
New Contributor II

Worked like a charm. Thanks!

0 Kudos