Select to view content in your preferred language

Choose Default/First Attachment in Attachment Viewer

225
2
Jump to solution
05-05-2025 09:16 AM
ISP_graynic
Frequent Contributor

Does anyone know of a way to choose which attachment shows first in the Attachment Viewer Instant App? I can't find any settings to choose how to sort the attachments if there are multiple attachments in a feature. I'm wanting an image to show first instead of other documents such as PDFs that are attached. I'm assuming this could be done via the webmap also but can't find any way to sort the attachments in a feature there either. 

0 Kudos
1 Solution

Accepted Solutions
KateBCarlson
Esri Contributor

You can do this in the web map's popup using Arcade. 

1. Add an image to the popup (+ Add content)

2. Next to URL, choose the curly brackets { }

3. Click + Add expression at the bottom

4. Apply the script below

 

//This script will concatenate a URL to show the first attachment of a feature.
//The First function will grab the ID for the first attachment of the feature
//part1 is the first part of the URL. You can find the URL by examining the attribute table and "View attachment"
 
var attachment = First(Attachments($feature)).ID
var part1 = https://services.arcgis.com/[feature's unique ID]/arcgis/rest/services/[the feature layer's name]/FeatureServer/0/"
var ObjectID = $feature.OBJECTID
var part2 = "/attachments/"

//Return a concatenated string, the URL for the feature's first attachment
return part1 + ObjectID + part2 + attachment

 

View solution in original post

2 Replies
hkomm
by
Occasional Contributor

Two potential solutions that come to mind (I haven't tested them, but they might be worth a try!)
 1. Open your feature layer with attachments in AGOL Map Viewer and configure the pop-ups.

hkomm_0-1748828217510.png


2. Use HTML/Arcade expressions within your pop-up to sort the attachments by file type.


If you haven't come across this link, it could be helpful - Pop-ups Essentials

KateBCarlson
Esri Contributor

You can do this in the web map's popup using Arcade. 

1. Add an image to the popup (+ Add content)

2. Next to URL, choose the curly brackets { }

3. Click + Add expression at the bottom

4. Apply the script below

 

//This script will concatenate a URL to show the first attachment of a feature.
//The First function will grab the ID for the first attachment of the feature
//part1 is the first part of the URL. You can find the URL by examining the attribute table and "View attachment"
 
var attachment = First(Attachments($feature)).ID
var part1 = https://services.arcgis.com/[feature's unique ID]/arcgis/rest/services/[the feature layer's name]/FeatureServer/0/"
var ObjectID = $feature.OBJECTID
var part2 = "/attachments/"

//Return a concatenated string, the URL for the feature's first attachment
return part1 + ObjectID + part2 + attachment