Select to view content in your preferred language

Arcade expression for pop-up attachment

777
6
Jump to solution
03-28-2024 07:29 AM
Rémi
by
Occasional Contributor

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
2 Solutions

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
Rémi
by
Occasional Contributor

Thanks a lot for your help

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
Occasional Contributor

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
Occasional Contributor

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
Occasional Contributor

Thanks a lot for your help

0 Kudos