Skip to main content

Is Arcade Attachments() supported with a protected service

Comments

4 comments

  • Brian Bieber

    Yes, it works with protected service.  Make sure your service is a Feature Service and not a Map Service.  I also think the related table need to be included in the Feature Service.   I used the following to get at the attachments.  It is almost a carbon copy of an Esri (or Geocortex) example.  I will try to find the link.

    function makeAttachmentLink(name, id, oid, url) {  
        return '<' + 'a ' + 'href="' + url + '/' + oid + '/attachments/' + id + '" target="_blank">' + name + '<' + '/' + 'a>';  
    }  

    function makeAttachmentLinks(serviceUrl, oidField) {  
        if (IsEmpty(oidField)) {  
            oidField = "OBJECTID";  
        }  
       
        var a = Attachments($feature);
        var result = "";
        //var years = [];
        var maxYear = 0;
        var curYear = 0;

        //find max year
        for (var i in a) {
            curYear = Number(Left(a[i].name,4));
            if (curYear > maxYear){
                           
            }       
            //years[i] = Left(a[i].name,4);
        }

        //add links for max year attachments
        for (var i in a) {
            curYear = Number(Left(a[i].name,4));
            if (curYear == maxYear){     
                 result += makeAttachmentLink(a[i].name, a[i].id, $feature[oidField], serviceUrl) + TextFormatting.NewLine;    
            }
        }  

        if (IsEmpty(result)) {  
            result = "None"  
        }  

        return result;  
    }  

    makeAttachmentLinks("https://arcgis server service/FeatureServer/0") 
    1
  • Berend Veldkamp

    Thanks I tried with a FeatureService, which indeed works!

    I don't suppose there's a workaround for that?

    0
  • Brian Bieber

    No, I do not think so.  From what I've seen, you need a Feature Service when using Arcade.  Plus some of the functionality is only available when publishing with Pro. I don't recall the exact details but to get Arcade to work as expected I switched from ArcMap to Pro.

    0
  • Berend Veldkamp

    Field operations seem to work, even with mapservices (e.g. $feature.myField * 100). I also can't think of reason why attachments would only work for featureservices, they work the same for both types. But so be it.

    0

Please sign in to leave a comment.