Select to view content in your preferred language

Convert a time field to UTC inside of a pop-up

954
4
Jump to solution
02-17-2022 01:19 PM
RyanBohan
Regular Contributor

Working on an issue with an incorrectly displayed time field.  I need to a field from a rest service to UTC to get the correct date/time  (below should be 7/10/2020 12:00am).  I don't own the rest service or I would just change it there.

RyanBohan_0-1645131682675.pngRyanBohan_1-1645131828122.png

I have tried to use arcade, but because of the way I am building the pop-up, I am getting issues with the calculation.

Any help would be great, thank you!

0 Kudos
1 Solution

Accepted Solutions
KristianEkenes
Esri Regular Contributor

Ok. I see the issue, you'll need to reference the expression in an expressionInfos object, which will assign it a name. Then you need to refer to that name within the popup content in the following format: {expression/expression-name}. It's the same syntax as referring to field names except you need to prefix the expression name with "expression/".

KristianEkenes_0-1645138560809.png

KristianEkenes_1-1645138573239.png

KristianEkenes_2-1645138597791.png

 

This is the live sample: https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-arcade/

Hopefully that helps.

View solution in original post

4 Replies
KristianEkenes
Esri Regular Contributor

Can you describe which issues you're seeing with the UTC calculation in Arcade? Was this the expression you used?

ToUTC($feature.data_project_create)
RyanBohan
Regular Contributor

Hi @KristianEkenes 

It's very possible I am applying the arcade in the wrong way.  I am getting this in the pop-up 

RyanBohan_2-1645135842141.png

 

RyanBohan_0-1645135300313.pngRyanBohan_1-1645135783336.png

Thank you for your help

0 Kudos
KristianEkenes
Esri Regular Contributor

Ok. I see the issue, you'll need to reference the expression in an expressionInfos object, which will assign it a name. Then you need to refer to that name within the popup content in the following format: {expression/expression-name}. It's the same syntax as referring to field names except you need to prefix the expression name with "expression/".

KristianEkenes_0-1645138560809.png

KristianEkenes_1-1645138573239.png

KristianEkenes_2-1645138597791.png

 

This is the live sample: https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-arcade/

Hopefully that helps.

RyanBohan
Regular Contributor

Thank you @KristianEkenes the screen shots and example are great and I got it working.  Thank for you help

0 Kudos