Select to view content in your preferred language

How to build REST attachment URL using Arcade

364
1
01-07-2025 08:30 AM
Labels (1)
TD1
by
Frequent Contributor

Been playing around with Arcade to build a REST URL which points to the photo attachments on the record.

I have 1,400 records with photo attachments (most have more than one attachment) and this is what I have so far but it's pulling the attachment ID and how do I handle separate URL links for each attachment on that record if there are multiple?

var Part1 =       "https://services.arcgis.com/Enter ID/arcgis/rest/services/ Enter Feature service/FeatureServer/0/"
      var ObjectID = $feature.OBJECTID
      var Part2 = "/attachments/"
      var AttachID = $feature.AttachID
      When($feature.CountAttachments > 0, Part1 + ObjectID + Part2 + AttachID, null)

0 Kudos
1 Reply
FlorianArtelt
Esri Contributor

Is this case, you should have is array of attachment IDs in the variable "AttachID".

You have to use a for-loop and go through each ID.

Something like this:

var attachid = [1, 2]
    var textstring = []

if (count(attachid)>0){
  for(var id in attachid){
    var textstringpart = "BaseURL/" + Text(attachid[id])

    push(textstring, textstringpart)
  }
}

return Concatenate(textstring, ", ")
 
If you want to have a clickable link, you need to have a couple of fields for each link.
0 Kudos