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

245
0
03-24-2021 08:22 PM
Labels (3)
JoeBryant1
Occasional Contributor II

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.

0 Kudos
0 Replies