Select to view content in your preferred language

Web Map Pop-up list only PDFs (not jpegs)

751
5
11-04-2022 08:03 AM
Labels (2)
KdeGroh
Emerging Contributor

I need help with a custom arcade script in order to provide attachments in a pop depending on file type. I have a JPEG and PDF attached to a Survey123 data point. 

KdeGroh_0-1667574177853.png

 

Tags (3)
0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

Can you share your Arcade expression? I'm assuming you're using the Attachments function? There is an optional types parameter to filter the resulting array based on its filetype. That should be all you need to accomplish this.

- Josh Carlson
Kendall County GIS
0 Kudos
KdeGroh
Emerging Contributor

I do not have an expression currently. I am still very new to writing expressions and I had no success in searching online for where to start. 

I was trying to use this site to start: Visualize Your Attachments in ArcGIS Online with Arcade (esri.com)

But I understand that this is more for the symbology and not filtering attachments in a pop-up

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Hey Josh, following along here.

It's pretty easy to get a list of the attachments with Attachments(), but do you know how to get a link to them?

I'm able to generate a list of names pretty easily, and even get a URL going, but I can't get a token for the items. 

var ret= []
//var urlbase = "Path to my feature class"
var attList = Attachments($feature, {"types":["application/pdf"]})

for (var att in attList) {
    Push(ret, attList[att].name)
    //var url = Concatenate([urlbase,$feature.OBJECTID,"attachments", attList[att].id, "?token="], "/")
    //Push(ret, url)
 }
return ret

Yields 

AlfredBaldenweck_0-1667861984543.png

Constructing the url instead yields a functional URL, but without figuring the token I can't actually link the attachments.

(Also for some reason I can't get the HTML for hyperlinks working, so I'm not bothering to put it here)

0 Kudos
KdeGroh
Emerging Contributor

Once the token is determined, would this yield only PDF attachments and not JPEGs? 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Yes. The second part of the Attachments() function filters them by file type.

These are the point's attachments. The PNG is filtered out.

AlfredBaldenweck_0-1667915453580.png

 

0 Kudos