Webhook capability in Survey123 is very helpful to automate process without make a code. you can follow this link for the details : Automating workflows with Survey123 and Microsoft Flow
I got some challenges when use it in Microsoft Flow especially about time and date.
- originally time and date from survey123 is EPOCH format.
- by default time zone form survey123 is UTC.
- I have needs to display time and date in proper string format.
Convert EPOCH to YYYY/MM/DD HH:mm:ss
if you access time and date from field directly from dynamic content, it will display epoch time. to show time and date as YYYY/MM/DD HH:mm:sss you can use expression instead of dynamic content.
expression syntax :
addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['dateTime'],1000) , 'HH:mm:ss')
this part ['feature']?['attributes']?['dateTime'] is time field in your featureservice.
it will return time and date like this : 2019-01-22 02:00:00 (please bear in mind this is UTC time zone)
Convert from UTC to My City Time Zone :
as you can see on the picture above, I added my time expression into add to time plugin. this plugin is default from Microsoft Flow to add interval time into your exisiting time. my city time zone is UTC +7. so I added 7 in interval form and select hour in time unit options.
the result will be like this : 2019-01-16T13:00:00.0000000
its return time and date with full string format.
Reformat time and date string:
in my case, I want to extract time from converted time and display it as short time pattern.I added Convert time zone plugin provided by microsoft flow. basically this plugin used for converting time zone, however there is an options to display format time and date format string. so I used "short time pattern" in format string options then convert time zone to same time zone due to my time has been converted in previous step by adding interval manually.
then I can use time in email body like this :
or use converted time in event calendar like this :
here is the whole diagram :
Any inputs are welcome