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'.
- Log in to Portal for ArcGIS and open the map in Map Viewer Classic.
- Click Details, and click Content.
- Click More Options next to the layer, and click Configure Pop-up.
- Scroll down to the Attribute Expressions section in the Configure Pop-up pane, and click ADD.
- 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')
- Provide a name for the Arcade expression and click OK.
- 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 the View HTML Source button to switch the view to HTML Source.
- 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>
- Click OK to close the Custom Attribute Display dialog box, and click OK again to close the Configure Pop-up pane.
- Click Save.
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 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.