Select to view content in your preferred language

Power Automate Flow from Survey123 Unix Timestamp

739
5
12-08-2022 06:06 AM
MT_JenAmes
Regular Contributor

I have a flow set up to use the ArcGIS "When a record is updated in a feature layer" trigger, and send an email with information about the feature layer. The feature layer was created with Survey123 Connect. I have a date field (WODate) in the form that I'd like to pass through on the email. However, Survey123 likes to use Unix instead of an easily readable format, so I get emails saying "Work Order Submitted on 1670432400000". I've gone through a couple different calculations that I've found here on Geonet and on other non-Esri forums, but none of them seem to be working. Any suggestions for how I can get "1670432400000" to read as "12/7/22" or "12/7/22 12:00 pm"?

 

These are the options I've tried so far:
formatDateTime(addSeconds('1970-1-1', Div(triggerOutputs()?['body/feature/attributes/WODate'],1000)), 'M/d/yy h:mm tt')
addseconds('1/1/1970', Div(WODate,1000) , 'MM/dd/yy')

0 Kudos
5 Replies
PhilLarkin1
Frequent Contributor

What outputs do you get with formatDateTime?

You might need a conversion in there. Give convertFromUtc a try. Note the time zone parameter.

 

convertFromUtc(concat(addseconds('1970-1-1', Div(triggerOutputs()?['body/feature/attributes/WODate'],1000),'yyyy-MM-dd hh:mm:ss'),'Z') ,'Pacific Standard Time','yyyy-MM-dd hh:mm:ss')

 

 

0 Kudos
MT_JenAmes
Regular Contributor

Thanks, I'm going to give this a try!

Update: Did not work. It just returned the whole calculation as a string. I copy/pasted the conversion you gave, and just updated the time zone, but it returned this in my email: 
convertFromUtc(concat(addseconds('1970-1-1', Div(triggerOutputs()?[1671037200000],1000),'yyyy-MM-dd hh:mm:ss'),'Z') ,'Eastern Standard Time','yyyy-MM-dd hh:mm:ss')


0 Kudos
SeanKMcGinnis
Esri Contributor

@MT_JenAmes  This post walks you through the steps to convert the the Epoch date to a human readable date.

I walked through the steps to convert the value you shared, 1670432400000, and converted it into the value are looking for with the following flow.

Screen Shot 2022-12-13 at 10.18.44 AM.png

 

In the 'Variable - Epoch Date' initialization, the expression is:

div(1670432400000, 1000)

 In the 'Variable - Human Readable Date' initialization, the expression is:

addSeconds('1970-1-1',variables('Unix Timestamp'), 'yyyy-MM-dd hh:mm:ss')

 

After testing the flow, here are the values:

Screen Shot 2022-12-13 at 10.22.50 AM.png

 

What is the output you are getting when you try and convert the values?

-sean
Sean McGinnis - ArcGIS for Microsoft 365 Product Manager
0 Kudos
MT_JenAmes
Regular Contributor

How do I get this information into a flow like this then?

MTJames_0-1671027580422.png

Because I don't have my fields available as an option to input for the value in the initial variable where I currently have it lined up. These are the only dynamic content options I have

MTJames_1-1671027654108.png

And if I try to put the variable in after the "Fetch updates..." I get an error saying that I can't set a variable that late in the flow.

I copy/pasted the date field into the first initialize variable value question, and tried to save the flow, and it won't let me, says it's an invalid integer.

MT_JenAmes_2-1671028815146.png

 

0 Kudos
SeanKMcGinnis
Esri Contributor

You cannot initialize a variable that late in the flow, but you can use the 'Set Variable' action to to set the variable's value as your 'Send Notification' iterator goes through each of the records in the webhooks payload from the 'Fetch Updates' action.

-sean
Sean McGinnis - ArcGIS for Microsoft 365 Product Manager
0 Kudos