Hi,
I have been struggling with showing attachments from one layer into another in a webmap for a bit now and am finally reaching out to the esri community blog gods.
I have two feature layers in a web map ("Beaver Obscured" and "Beaver"). I would like for the attachments in "Beaver" to show up in the popup for "Beaver Obscured". "Beaver Obscured" does not have attachments but does have a shared globalID with "Beaver". Is there a way to take the attachments from "Beaver" and add them to the popup of "Beaver Obscured" in my webmap with arcade? I thought I could do this based on their globalIDs , as I've read through several examples of how to do this with related data but I am struggling to get those scripts to work with shared globalIDs.
Does anyone have suggestions with arcade, or other work arounds?
Thanks in advance,
Becca
Solved! Go to Solution.
Okay so actually I "figured out" the comma problem by deleting the regualar brackets after Push and then just enter new ones. So there's that. So now I'm very close! I wrote the code as an attribute expression:
// related table layer
var fs = FeatureSetById($map, "189ffea4bbf-layer-175")
// get matching feature based on GlobalID to GUID Relationship
var match = First(Filter(fs, `CompRel = '${$feature['GlobalID']}'`))
console ("fs: "+fs);
console ("match: "+match);
// get matching feature's attachments
var atts = Attachments(match)
console ("atts:" + atts)
// push attachment urls into array
var urls = []
for (var att in atts) {
Push (urls,`<img src="https://gis.edenprairie.org/maps/rest/services/Internal/CodeViolations/FeatureServer/1/${match['OBJECTID']}/${atts[att]['id']}"></img>`)
}
return Concatenate(urls, '<br>')
and then go add that expression into a text section in the popup but just get this:
Hey Zach,
Have you been able to find a solution for this? It's happening on my end also.
I got it to work!
The URL link was missing the /attachments/ portion in between /${match['objectid']}/${atts[att]['id']}"
Hope this helps!
The only problem with this solution is the token issue, right?
I adapted the code to show certain attachments based on their name and everything works fine, except that when I click on the link, it always asks me for an access token (in ArcGIS Online). I have an admin login, I own the layer and the link is exactly the same as when I access the attachment directly in the feature layer (except for the token).
In ArcGIS Enterprise, I can access without the "?token=" in the url.
Is this really the expected behavior or am I missing something? If so, is there no way to automatically generate tokens for the user from Arcade?
Oh good to know! I actually abandoned trying after a while, since the project I wanted it for is used exclusively in Field Maps or Experience Builder, and there were some acceptable workarounds. I'll keep this in mind for the future though!