HOW TO

Display hyperlinks in pop-ups based on conditions using Arcade expressions in Portal for ArcGIS and ArcGIS Online Map Viewer Classic

Last Published: November 16, 2022

Summary

In Portal for ArcGIS and ArcGIS Online Map Viewer Classic, Arcade expressions can be used to apply conditional formatting in the pop-up to hide or display specific text or hyperlinks to external web pages pertaining to the field value. This article provides an example and instructions using Arcade expressions to display hyperlinks based on conditions in pop-ups of Map Viewer Classic.

Procedure

  1. Open the map in Map Viewer Classic. Click Details, and click Content.
  2. Click More Options The More Option icon next to the layer next to the layer, and click Configure Pop-up.
  3. Scroll down to the Attribute Expressions section in the Configure Pop-up pane, and click ADD. For this workflow, two Arcade expressions are required.
  4. In the editor window, specify a name for the new expression.
  5. In the Expression dialog box, insert the following Arcade expression to define the text displayed if the condition is met and vice-versa in the Expression section:
return iif($feature.<fieldName> == <fieldValue>, '<fieldValue1>', '<fieldValue2>')

The code below is an example of the full working script.

return iif($feature["LEVEL_NO"] == 6, 'College Application Available', 'College Application Not Available')
  1. Click Test to view a preview of the expression result. If the required result is achieved, click OK.
Specifying the Arcade expression in the Map Viewer Arcade expression editor window
  1. Click ADD to open the Arcade expression editor window to specify the second Arcade expression.
  2. In the editor window, specify a name for the new expression.
  3. In the Expression dialog box, insert the following Arcade expression to configure the display of the link based on one of the two values, 'none' (hide) or 'inline' (show) in the Expression section:
return iif($feature.<fieldName> == <fieldValue>, 'inline', 'none')

The code below is an example of the full working script.

return iif($feature["LEVEL_NO"] == 6, 'inline', 'none')
  1. Click Test to view a preview of the expression result. If the required result is achieved, click OK.
Specifying the Arcade expression in the Map Viewer Arcade expression editor window
  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.
Changing the pop-up display option
  1. Click CONFIGURE to open the Custom Attribute Display dialog box.
Selecting Configure to edit the pop-up further in the Configure Pop-up pane
  1. Click the View HTML Source button to switch the view to HTML Source.
  2. In the Custom Attribute Display dialog box, insert the following HTML script, and click OK.
{expression/expr0} <a href="<webpageURL>" style="display:{expression/expr1}" target="_blank" rel="nofollow">(<b><URLDisplayText></b>)</a>

The code below is an example of the full working script.

{expression/expr0} <a href="https://portlandbiblecollege.org/admissions/apply-now/" style="display:{expression/expr1}" target="_blank" rel="nofollow">(<b>Apply Now</b>)</a>
Specifying the HTML script in the Custom Attribute Display dialog box
  1. Click OK in the Configure Pop-up pane to apply the pop-up configuration.
The Configure Pop-up pane in Map Viewer Classic

The image below shows the configured pop-up whereby the pop-up displays the hyperlink when the point selected is a college.

The configured pop-up window displaying the hyperlink when the point feature is a college

The image below shows the configured pop-up whereby the pop-up does not display the hyperlink when the point selected is not a college.

The configured pop-up window with the hidden hyperlink when the point feature is not a college

Article ID:000028533

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

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options