HOW TO

Display only features with attachments in Attachment Viewer

Last Published: May 3, 2024

Summary

Recently the "Only display features with attachments" setting was removed from the Attachment Viewer template for ArcGIS Instant Apps. As a result, in a map-focused layout features without attachments populate spaces in the Attachments panel with a 'broken image' icon, as shown in the following screenshot. 

features without attachments populate spaces in the Attachments panel

This article provides a workaround so that features without attachments can be filtered out of the Attachment Viewer apps, and only features that have attachments appear in the Attachments panel, as shown in the image below.

afterImage2.jpg

Procedure

Note:
You must be the data owner to make these changes.

Follow the below steps:

  1. Go to the Item details page of the layer(s) where attachments are stored.
  2. Click the Data tab at the top.
  3. In the Data section, click the Fields button, shown in the next image, to access the fields view.
Data section showing Fields button
  1. Once in the fields view, click + Add to add a new field. Add a new String field and name the field something like 'AttachPresent'. Click the Add New Field button, as shown below.
addfieldNew.jpg
  1. Click the Table button to go back to the table view.
  2. Find the new field that was just added and click on the field to start calculating it.
arcadeCalc.jpg
  1. Choose the Arcade option as the language to use to calculate the field.
  2. In the expression builder copy and paste in the followoing  expression:
// Create a field that shows how many attachments to filter on
 
var stands = $feature
var featAttach = Count(Attachments(stands))
 
// Value that will be returned if there are attachments present
var yes = "Yes"
// Value that will be returned if there are no attachments present
var none = "None"
 
IIf(featAttach > 0, yes, none)
  1. Once the expression is pasted in, click the Test button to confirm the expression works. This is shown in the image below.
ArcadeCalc_test.jpg
  1. Once confirmed that the expression is successful, click the OK button to calculate the field. The records are then calculated.
  2. Confirm this was successful by checking the new field you created with the Photos and Files field, shown in the next image:
    • If a feature has attachments the new fields values should be Yes
    • If there are no attachments available you should see None
AttachFieldNew.jpg
  1. Now go and open this layer up in a web map, or the web map you are planning to use in the Attachment Viewer app.
  2. In the Map Viewer, make sure the Layer with Attachments is active and go to the Filter tab.
filterinMapViewer.jpg
  1. Click on the + Add expression button to add a new expression.
  2. In the top drop-down menu choose the field created in step 4, and under Expression, keep the middle drop-down menu as is, and from the bottom drop-down menu choose the Yes value, as shown below.
filterexpression.jpg
  1. Click Save. The map should then update to only show features with attachments.
  2. Save the web map and now it should be ready for Attachment Viewer and only showing features that have attachments. 


 
 

Article ID:000026475

Software:
  • ArcGIS Server
  • Online
  • ArcGIS Pro

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic