Arcade reference to external sources

829
3
11-23-2020 10:48 AM
by Anonymous User
Not applicable

Hello Community,

I need some help with this code since I am new to coding.

I have created a custom pop-up that allows me to gather information through intersecting.

Now I wanted to get to the next level-creating links with intersecting. I created two separate arcade expressions;

 

One for the intersection: 

var intersectLayer =Intersects(FeaturesetbyName($map, "landrecords - Parcel Map"), $feature)
var results = ""
var baseweb ="http://pw.lacounty.gov/sur/nas/landrecords/parcel/PM"
for (var f in intersectLayer){​​​
    if (results ==""){​​​
        results = f.Reference;
    }​​​   else{​​​
        results += ", " + f.Reference;
    }​​​
}​​​
return results

 

One for the hyperlink:

var baseweb = "http://pw.lacounty.gov/sur/nas/landrecords/parcel/PM"
var intersectLayer = Intersects(FeaturesetbyName($map, "landrecords - Parcel Map"), $feature)
 
for (var f in intersectLayer){​​
    return baseweb + MID(f.REFERENCE,2,3) + "/" + f.REFERENCE + ".pdf"
}​​
 
Results:
 

The result is circled in blue, however the links both send you to the same document.

image.png

 

Any help would be appreciated.

Thank you.

 

-Matthew

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi @Anonymous User ,

 

A couple of comments/questions on what you are trying to achieve:

  • I assume that the first expression creates the text (comma separated list of "References") and the second the hyperlink. Is that correct?
  • You should not use a return statement in a loop in case you want to return only the first item. Return inside a loop will return with the first element. You can use the "First" function to get the first feature from the intersection results and simply read out the attribute you need.
  • The hyperlink that is returned will be something like "http://pw.lacounty.gov/sur/nas/landrecords/parcel/PM345/123456789.pdf" if the reference value is "123456789". Is that the correct URL you are looking for? 
0 Kudos
by Anonymous User
Not applicable

Xander,

 

Yes the first comment/question is correct.

The reason why I want a loop is because there are several resources/polygons stacked on one another. I want to return all of them that are within a click. I'm not sure if that answers the second statement correctly. I will try the first function and see what I come up with.

Yes, that is the correct URL I am looking for.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @Anonymous User ,

 

Thanks for clarifying! 

You mention that you want to retrieve multiple hyperlinks since there can be multiple resources stacked on one another. A couple of things to keep in mind:

  • To return multiple results from a single expression, you can use the same logic as for the list of references (in each loop add a value to the result)
  • However, if a single text contains multiple URLs, it will not appear as valid URL in the pop-up
  • If each feature provides a single URL in the pop-up the fact that they are stacked does not yield any problems. 

On the other hand, you mentioned earlier that you obtain the same URL for different features. I don't see a reason for this in the Arcade expression and I would first look at the data and try some different URL's manually in the browser to see what happens and that there is no redirect causing this behavior. 

0 Kudos