HOW TO

Apply Arcade expression conditional functions to display an image in a pop-up in Portal for ArcGIS Map Viewer Classic

Last Published: July 13, 2022

Summary

In Portal for ArcGIS Map Viewer Classic, Arcade conditional functions can be used to reference a field of an attribute table to display an image in a pop-up when the conditions are met in the Arcade expression.

As an example, this article provides instructions using the Arcade expression to apply conditions to the pop-up display for images to be shown only when the Local Deliveries Allowed field value is not 'N' in Portal for ArcGIS Map Viewer Classic.

Procedure

Note:
The workflow below utilizes the replace Arcade function to replace the Truck Restriction field alias, 'truckrestr' field value from 'N' to 'No', and 'Y' to 'Yes'.
  1. Log in to Portal for ArcGIS and open the map in Map Viewer Classic.
  2. Click Details, and click Content.
  3. Click More Options The More Option icon next to the layer next to the layer, and click Configure Pop-up.
The Configure Pop-up option in the Contents pane
  1. Scroll down to the Attribute Expressions section in the Configure Pop-up pane, and click ADD.
Click ADD icon in the Configure Pop-up pane
  1. Specify the IIf logical function to apply a conditional logic to hide a field. Specify none for trueValue, and inline for falseValue. The sample Arcade expression below hides the 'truckrestr' field if the value is 'N'.
return iif($feature.truckrestr == 'N', 'none', 'inline')
  1. Provide a name for the Arcade expression and click OK.
Specifying the IIf function in the Arcade expression dialog box and providing a name for the Arcade expression
  1. Under the Pop-up Contents section in the Configure Pop-up pane, for Display, click A custom attribute display from the drop-down menu. Click CONFIGURE to open the Custom Attribute Display dialog box.
Click Configure in the Configure Pop-up pane
  1. Click the View HTML Source The View HTML Source icon button to switch the view to HTML Source.
  2. Specify the HTML code within the Custom Attribute Display dialog box area to customize the style of the pop-up. In the example below, the pop-up is customized to reveal an image item shared in the ArcGIS organization when the 'truckrestr' field value is not 'N' by referencing the newly created Image Condition {expression/expr1} Arcade expression.
<div style="display:{expression/expr1};"><img alt="" src="https://<portal_URL>/portal/sharing/rest/content/items/<itemID>/data?token=<tokenID>" /></div>
Specifying the HTML code within the Custom Attribute Display dialog box
  1. Click OK to close the Custom Attribute Display dialog box, and click OK again to close the Configure Pop-up pane.
  2. Click Save.
Saving the custom attribute display pop-up configuration in Portal for ArcGIS Map Viewer Classic

The image below displays the pop-up when the 'Truck Restriction' field value is 'No'. The logo does not appear in the pop-up.

The custom attribute display pop-up when the Truck Restriction field value is N

The image below displays the pop-up when the 'Truck Restriction' field value is not 'No'. The logo appears in the pop-up below the table.

The custom attribute display pop-up when the Truck Restriction field value is not N

Article ID: 000027864

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