How to use Arcade Expressions
Just upgraded to 4.12 and trying to use this new functionality. It seems like it's working, but when I add the expression to my feature long description nothing shows up.
I'm trying to use a super simple expression that creates and email address for our staff by using a different field that has their full names:
Replace($feature.Name," ",".") + "@brooklynpark.org"
Sample Input: John Nerge
Sample Output: John.Nerge@brooklynpark.org
Then I'm trying to use that in an <a> tag with a mailto: link. I'm not getting any errors, and the mailto link is working, but it's not loading the email address. The Arcade expression value also doesn't show up when I put it directly into the feature long description.
I verified the expression works with my dataset in ArcGIS Online and in Pro. Should the same expression work in GE, or am I misunderstanding how Arcade Expressions work in GE?
0
-
You probably figured this out already, but did you create a token (name) for the expression and then use the token in your Feature Details (not the expression itself)? So the token would be something like "Email" on the expressions tab, and then in your feature details you would insert {Email} where you wanted it to go. I figured out my expression with the help of your post ($feature.fieldname) so I thought our two posts might help someone else! 0 -
Thanks Heather, I had specified a token, but I still appreciate the help. The Arcade piece is working, it seems like the issue is with the <a> tag not working properly with it.
Denise, try this code out:
var cities = FeatureSetByName($map,"Multi Tenant Buildings")
var intersectLayer =Intersects(cities, $feature)
//Loop through the intersect layer to see if the feature intersect any records in the city limits layer
for (var f in intersectLayer){ var message = 1 }
//If an intersecting record was found, return the name, if not, return "Kern County"
iif(message==1,$feature.Name,"Kern County")0 -
Oops, missed a value for you, here's the right code:
var cities = FeatureSetByName($map,"City Limits")
var intersectLayer =Intersects(cities, $feature)
//Loop through the intersect layer to see if the feature intersect any records in the city limits layer
for (var f in intersectLayer){ var message = 1 }
//If an intersecting record was found, return the name, if not, return "Kern County"
iif(message==1,$feature.Name,"Kern County")0 -
Thank you, John! Unfortunately, that didn't seem to do the trick. Does it matter that the city limits are in a different map service than the point layer (the point layer is actually a feature layer)? Also, it shouldn't matter if the city limits are on or off, correct?
Thanks,
Denise0 -
It shouldn't matter that the city limits are in a different map service or are on/off. For the feature layer question, I'm not sure. As a next step, I'd recommend bringing your city limits and points into an ArcGIS Online map and trying to set up the Arcade in the point's pop-up. AGO has error messaging, so when you test the code it should hopefully give you some more info. 0 -
I got this message when I tried it in AGOL:
Execution Error:Runtime Error: Identifier Not Found. message0 -
Okay, so less than helpful.
Try running just these two lines in AGO on your point layer:
var cities = FeatureSetByName($map,"City Limits")
Intersects(cities, $feature)
Make sure your city limits layer is called City Limits (or update the Arcade code to match what it's called).
If it works, you'll get back either a result of False or a feature set table showing the values from an intersecting City Limits feature.0 -
Thanks, John. The layer is definitely called "City Limits". I got back a result of False. 0 -
Hmm, a little concerned, but at least it's not an error? Here's some new code to try. It'll run the intersect, then count the number of intersecting features. If there aren't any it'll return your default "Kern County" value, but if it does then it'll return the city name from the City Limits layer.
var cities = FeatureSetByName($map,"City Limits")
var intersectLayer = Intersects(cities, $feature)
if (count(intersectLayer) == 0) {
return "Kern County"
}
else {
for (var f in intersectLayer){
var city = f.Name
}
return city
}0 -
Hmm, now it's giving me this error:
Execution Error:Invalid Parameters for Count0 -
Any chance your map layers are publicly accessible? If not, we could take this offline and set up a screen share (john.nerge@brooklynpark.org) 0 -
Instead of using FeatureSetByName, try FeatureSetById($map,'10') with in this case '10' being the Geocortex layerid in the map,
Have a look at the Arcade syntax in the LA County sample site > Base Layers > Administrative Areas > Community Boundaries > TOPTREES Arcade expression using Intersects.
Cheers...Rick0 -
BTW, there are other Arcade expressions in this layers:
LA County sample site > Base Layers > Administrative Areas > Health Districts
LA County sample site > Base Layers > Administrative Areas > Census Tracts0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
13 Kommentare