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.
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.
Procedure
Note:
You must be the data owner to make these changes.
Follow the below steps:
- Go to the Item details page of the layer(s) where attachments are stored.
- Click the Data tab at the top.
- In the Data section, click the Fields button, shown in the next image, to access the fields view.
- 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.
- Click the Table button to go back to the table view.
- Find the new field that was just added and click on the field to start calculating it.
- Choose the Arcade option as the language to use to calculate the field.
- 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)
- Once the expression is pasted in, click the Test button to confirm the expression works. This is shown in the image below.
- Once confirmed that the expression is successful, click the OK button to calculate the field. The records are then calculated.
- 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
- 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.
- In the Map Viewer, make sure the Layer with Attachments is active and go to the Filter tab.
- Click on the + Add expression button to add a new expression.
- 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.
- Click Save. The map should then update to only show features with attachments.
- Save the web map and now it should be ready for Attachment Viewer and only showing features that have attachments.