Arcade expression for pop-up attachment

334
6
Jump to solution
a month ago
Rémi
by
New Contributor II

Hi, I found in this post https://community.esri.com/t5/arcgis-online-blog/show-attachments-in-pop-ups-with-arcade/ba-p/890588 how to display the first attachment. I'd like to view the other attachments by retrieving the list of attachment identifiers using arcade to calculate a new field:

//calculate the attach IDs field
function IDs(f){
return f.ID;
}

var Attach_ = Attachments($feature);
var AttachIDs = Map(Attach_, IDs);
return Concatenate(AttachIDs,',');

I don't understand why this isn't working. Can you help me?

Thanks,

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

You can do it with a simple loop, no need to use Map (though it would make for more concise code).

var atts = Attachments($feature)
var ids = []

// loop through attachments and get the ids
for (var a in atts) {
  Push(ids, atts[a]['ID'])
}

return Concatenate(ids, ', ')
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
6 Replies
jcarlson
MVP Esteemed Contributor

Hard to say why it isn't working. Try adding a couple Console statements to see what each step is doing, as that can identify where the process is breaking down.

/calculate the attach IDs field
function IDs(f) {
  return f.ID;
}

var Attach_ = Attachments($feature);
Console(Text(Attach_));
var AttachIDs = Map(Attach_, IDs);
Console(Text(AttachIDs))
return Concatenate(AttachIDs,',');
- Josh Carlson
Kendall County GIS
Rémi
by
New Contributor II

Thank you for your reply. I get the following error : invalid expression. Error on line 8 Unknown function

0 Kudos
jcarlson
MVP Esteemed Contributor

Are you running this expression in ArcGIS Enterprise? Map was introduced at 11.0, so if you're on an earlier version, you won't have access to it.

- Josh Carlson
Kendall County GIS
0 Kudos
Rémi
by
New Contributor II

Unfortunately, I'm in version 10.9!

I don't know how i can retrieve attachment identifiers...

Thanks,

0 Kudos
jcarlson
MVP Esteemed Contributor

You can do it with a simple loop, no need to use Map (though it would make for more concise code).

var atts = Attachments($feature)
var ids = []

// loop through attachments and get the ids
for (var a in atts) {
  Push(ids, atts[a]['ID'])
}

return Concatenate(ids, ', ')
- Josh Carlson
Kendall County GIS
0 Kudos
Rémi
by
New Contributor II

Thanks a lot for your help

0 Kudos