Select to view content in your preferred language

Alternative to First

1039
4
Jump to solution
08-18-2021 04:44 PM
ChrisGAEG
Regular Contributor

Hi there, 

I have a rule where I am trying to see if a line intersects a specific polygon. I was using First, but realized the rule wouldn't flag if it went through another polygon first, then intersected my flag polygon. Is there a way to return a list and then flag if my polygon(cab_id == 'SDY-HUT') is in that list? This is the code I am using. 

var cabs = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries_copy", ["cab_id"])

var cabsInt = Intersects(cabs, $feature)

var cabSpliceInt = First(cabsInt)

if (cabSpliceInt == null) return {"errorMessage": "Please edit inside a cabinet boundary"}

if (cabSpliceInt.cab_id == 'SDY-HUT')

return false;

else return true;

 

Thanks! 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
HusseinNasser2
Esri Contributor

You can continue using first but first (no pun) you have to add an additional filter against the polygon you want. Push the query all the way to the DB.

 

var cabs = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries_copy", ["cab_id"], false)

var filteredCabs = filter(cabs, "cab_id='SDY-HUT'")
var cabsInt = Intersects(filteredCabs , $feature)

var cabSpliceInt = First(cabsInt)

if (cabSpliceInt == null) return {"errorMessage": "Please edit inside a cabinet boundary"}
 
 return true;

 

View solution in original post

0 Kudos
4 Replies
JohannesLindner
MVP Alum

 

var cabs = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries_copy", ["cab_id"])
var cabsInt = Intersects(cabs, $feature)
// just check the intersected feature set
if (cabsInt == null || Count(cabsInt) == 0) {
  return {"errorMessage": "Please edit inside a cabinet boundary"}
}
// filter cabsInt for your flagged polygon
var sdy_hut = First(Filter(cabsInt, "cab_id = 'SDY-HUT'"))
if (sdy_hut == null) {
  return false
}
return true

 


Have a great day!
Johannes
0 Kudos
HusseinNasser2
Esri Contributor

You can continue using first but first (no pun) you have to add an additional filter against the polygon you want. Push the query all the way to the DB.

 

var cabs = FeatureSetByName($datastore, "Proposed_OLT_LCP_Boundaries_copy", ["cab_id"], false)

var filteredCabs = filter(cabs, "cab_id='SDY-HUT'")
var cabsInt = Intersects(filteredCabs , $feature)

var cabSpliceInt = First(cabsInt)

if (cabSpliceInt == null) return {"errorMessage": "Please edit inside a cabinet boundary"}
 
 return true;

 

0 Kudos
ChrisGAEG
Regular Contributor

Okay great, this makes sense. What is the syntax for using a list in this case? What is the Arcade equivalent of "IN"? I want to do something like the following - 

var filteredCabs = filter(cabs, "cab_id IN ('SDY-HUT', 'ESC-C02', 'ESC-C04')")
0 Kudos
HusseinNasser2
Esri Contributor

That statement is correct and should work

 

p.s. it is not Arcade, it is SQL.