<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Multiple Literal Strings in Arcade in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/multiple-literal-strings-in-arcade/m-p/1222630#M4705</link>
    <description>&lt;P&gt;It looks like the second "find the closest thing" loop is incomplete, you need to sort your list and return the first result like you did above.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 20:36:09 GMT</pubDate>
    <dc:creator>DavidSolari</dc:creator>
    <dc:date>2022-10-17T20:36:09Z</dc:date>
    <item>
      <title>Multiple Literal Strings in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/multiple-literal-strings-in-arcade/m-p/1222572#M4703</link>
      <description>&lt;P&gt;I'm trying to create a calculated expression to populate a value in one of my fields. The expression gets the address of a feature that's within 100 feet of the feature the user is adding. If the expression doesn't get an address I want it to do the same process but with a different layer. I'm using literal strings in Arcade to populate the field. Can I not use multiple literal strings in the expression? Below is my Arcade expression.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (IsEmpty(Geometry($feature))){
    return null
}

var case = FeatureSetByName($map,"Active Container Related SRs")

var bufferedLocation = Buffer($feature, 100, "feet")
var candidateParcels = Intersects(case, bufferedLocation)

var featuresWithDistances = []
for (var f in candidateParcels){
    Push(featuresWithDistances,
        {
            "distance": Distance($feature, f, "feet"),
            "feature": f
        }
    )
}

function sortByDistance(a,b){
    return a["distance"] - b["distance"]
}

var sorted = Sort(featuresWithDistances, sortByDistance)

var closestFeatureWithDistance = First(sorted)

if (IsEmpty(closestFeatureWithDistance)){
    // return null
    var rcase = FeatureSetByName($map,"Active Recycling Container Related SRs")
    var rParcels = Intersects(rcase, bufferedLocation)
    var recycle = []
    for (var i in rParcels){
        Push(recycle,
            {
                "distance": Distance($feature, i, "feet"),
                "feature": i
            }
        )
    }
    return `${recycle["feature"]["IncidentAddress"]}`
}

return `${closestFeatureWithDistance["feature"]["IncidentAddress"]}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 18:07:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/multiple-literal-strings-in-arcade/m-p/1222572#M4703</guid>
      <dc:creator>michael_vetter</dc:creator>
      <dc:date>2022-10-17T18:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Literal Strings in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/multiple-literal-strings-in-arcade/m-p/1222630#M4705</link>
      <description>&lt;P&gt;It looks like the second "find the closest thing" loop is incomplete, you need to sort your list and return the first result like you did above.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 20:36:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/multiple-literal-strings-in-arcade/m-p/1222630#M4705</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2022-10-17T20:36:09Z</dc:date>
    </item>
  </channel>
</rss>

