Select to view content in your preferred language

Return "name" value from an Attachment Dictionary/Array?

787
2
03-24-2021 08:22 PM
JoeBryant1
Frequent Contributor

I'm trying to make my attachment file names (pdf reports) searchable/discoverable the same way other feature service attributes are searchable with the Search widget.

I don't see a way to access and join the _ATTACH table that was created in the GDB in Pro before I published (this table is not part of my feature service). So instead I am going to calculate the attachment file names into a new field and add that field to the searchable fields in the widget.

From what I can tell, you can't easily just return the "name" or 2nd item from the attachment dictionary using the Attachment($feature) function. For instance:

var att = Attachments($feature)[1]
return att

->  Execution Error:Runtime Error: Out of Bounds.

And

var att = Attachments($feature).name
return att

-> Execution Error:Runtime Error: Cannot call member property on object of this type. name

To get around this I am splitting the array twice and returning the 2nd position:

var att = Attachments($feature)
return Split((Split(Text(att), ',',2)[1]), ':')[1]

-> "Report.pdf"

Is there a better way that I am missing?

 

PS: It now looks like this workaround fails when there are more than 1 attachments. I'd like to concatenate all the attachment files names (they aren't for display, just for key words to search) into this field if there is not a better way to make attachment names searchable.

2 Replies
NickCoughlin
New Contributor

Hi Joe, 

I'm attempting to replicate the same function in arcgis online without having to export my hosted feature layer to a GDB and work from the attachments table in pro. Were you able to find a solution?

0 Kudos
JoeBryant1
Frequent Contributor

Hi Nick, I'm racking my brain from 3 years ago, but I don't think I found a solution using ArcGIS Online. I can't remember if I gave up, and/or tried an entirely different approach, possibly using a combination of Excel and ArcGIS Pro.

Let us all know if you figure something out!

0 Kudos