Hi, I am hoping someone can help me here, I am fairly new to Arcade.
I am trying to use arcade to show an image attachment in a pop-up in AGOL.
I can get it to work ok using the code below as long as all features have an attachment.
var Part1 = "https://services8.arcgis.com/OxmrsInax8iIPqdy/arcgis/rest/services/Civils_Data_Collection/FeatureSer..."
var ObjectID = $feature.OBJECTID
var Part2 = "/attachments/"
var AttachID = First(Attachments($feature)).ID
var Token = "?token=I HAVE REMOVED THIS.
return Part1 + ObjectID + Part2 + AttachID + Token
However, when I come across a feature without an attachment the code returns this.
Execution Error:Runtime Error: Cannot call member method on null. ID
Is there an easy way to deal with these null values?
Thanks in advance.
var attach = Attachments($feature)
if(Count(attach) == 0) {
return "no attachments"
}
var Part1 = "https://services8.arcgis.com/OxmrsInax8iIPqdy/arcgis/rest/services/Civils_Data_Collection/FeatureSer..."
var ObjectID = $feature.OBJECTID
var Part2 = "/attachments/"
var AttachID = First(attach).ID
var Token = "?token=I HAVE REMOVED THIS.
return Part1 + ObjectID + Part2 + AttachID + Token
Thanks for the reply, I will give it a go.
Adrian
How do you generate the token and ensure it works for the user??