I need to display attachments from a secure service in a popup, filtered by keyword. I can retrieve and filter the attachments using Arcade, but I can't seem to return the attachments to the popup. I'm hoping it's just a syntax issue, but I'm starting to wonder if this is even possible.
Here's my latest attempt:
var keyword = "my_keyword";
var atts = Attachments($feature);
var filteredAttachments = [];
for (var i = 0; i < Count(atts); i++) {
var attachment = atts[i];
if (attachment.keywords == keyword) {
Push(filteredAttachments, attachment);
}
}
Console(filteredAttachments)
return {
"attachment": filteredAttachments,
"type": "attachment",
"displayType": "auto"
}
This logs the following to the console, so everything is good up to the return statement.
[{"id":2,"name":"Discrepancies_image-20240321-155540-91b088a433494fb5aebd156de9c225e4-75a31dfa6c20461183d7004d680f0a78.jpg","contenttype":"image/jpeg","size":244565,"exifinfo":null,"keywords":"my_keyword"}]
I can't use the method of constructing the attachment URL because there's no way to provide a token. I've tried a dozen different iterations of the return statement.
Is it possible to filter attachments by keyword in Map Viewer popups?