HOW TO

Display data from a related table and date field value as per the local machine time zone using Arcade Expression

Last Published: August 3, 2022

Summary

In Portal for ArcGIS, date attributes displayed in pop-ups in Map Viewer are by default in the UTC time zone. However, it is possible to customize the pop-up display to project dates in the local machine time zone. This article provides instructions to customize a pop-up to display data from a related table and date field value as per the local machine time zone using Arcade Expression in Portal for ArcGIS Map Viewer.

Procedure

  1. Open the map in Map Viewer. Click Layers on the Contents (dark) toolbar, and select the layer with the pop-up for editing. In this example, the Capital Projects Q2 2021 All layer is selected.
The Map Viewer Contents (dark) toolbar with the Layers tab
  1. Click Configure pop-ups on the Settings (light) toolbar, and click Options > Attribute expressions.
The Map Viewer Pop-ups pane used to navigate to the Map Viewer Pop-up expressions pane
  1. Click + Add expression to open the Arcade expression editor window.
The Map Viewer Pop-up expressions pane with the Add expression icon
  1. Specify the following Arcade expression in the Expression window:
var <variableName1> = OrderBy(FeatureSetByName(<inputFeature>,"<relationshipName>"), "<fieldName1>");
var <variableName2> = Count(<variableName1>);

var <variableName3> = "";
if (<variableName2> > 0) {
    var <variableName4> = First(<variableName1>);
    <variableName3> = $feature["<fieldName2>"] + " " + Text(ToLocal($feature["fieldName1"]), "<dateFormat> <timeFormat>");
}

return relatedinfo;
  1. Rename the New expression, click Test to view a preview of the expression result, and click OK.
Specifying the Arcade expression in the Map Viewer Expression window

The following code block demonstrates the full working expression.

var relatedrecords = OrderBy(FeatureSetByName($map,"202108_Capital_Projects - Capital_Projects_Q2_2021_All"), "ACTUAL_START_DATE_UTC");
var cnt = Count(relatedrecords);

var relatedinfo = "";
if (cnt > 0) {
    var info = First(relatedrecords);
    relatedinfo = $feature["PROJECT_PHASE"] + " " + Text(ToLocal($feature["ACTUAL_START_DATE_UTC"]), "D/M/Y h:MM A");
}

return relatedinfo;
  1. Click the Previous button above the newly created Arcade expression in the Pop-up expressions pane.
The Map Viewer Pop-up expressions pane with the Previous icon above the newly added expression
  1. Click Fields list to expand the list of fields displayed in the pop-ups, and click Select fields.
The Map Viewer Pop-up expressions pane displaying the location of the Fields list section
  1. Check the expression field under the Expressions section, and click Done.
The Map Viewer Select fields pane to select fields to be displayed in the pop-up

The image below shows the CONVERT_ACTUAL_START_DATE_UTC field with the project phase, date, and time values after using the Arcade expression.

The end result of the pop-up display in Portal for ArcGIS Map Viewer

Article ID: 000027918

Software:
  • ArcGIS Online
  • Portal for ArcGIS

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options