<?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: Arcade: Can you reference an existing expression in another expression? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083748#M41472</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/260915"&gt;@KeithBurdette1&lt;/a&gt;&amp;nbsp;- By chain I meant use Filter and FeatureSet in the same call to reduce round trips to the server. But you're spot on - to return multiple attributes from the related records, what you can do is create an empty string, loop through the featureSet, and add records to the string. Here is a quick example of both:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var globalId = $feature.GlobalID;
var fset = Filter(FeatureSetByName($map,"RelatedFeatures"), 'RELATEFIELD = @globalId');
var returnString = "";
for (var f in fset) {
    returnString += "Related Record # " + f.NUMBER_RELATED
    returnString += TextFormatting.NewLine
    returnString += f.TEXT_RELATED
    returnString += TextFormatting.NewLine
    returnString += "-----------------"
    returnString += TextFormatting.NewLine
}

return returnString&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Returns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Peter_Klingman_0-1627509071580.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/19592i47872B4B451308ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Peter_Klingman_0-1627509071580.png" alt="Peter_Klingman_0-1627509071580.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Peter&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 21:52:00 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-07-28T21:52:00Z</dc:date>
    <item>
      <title>Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318610#M15939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's say I have&amp;nbsp;&lt;SPAN style="color: #4c4c4c;"&gt;{expression/expr0} written, and I want to write a new expression to use the same output but scrubbed a different way. Can I reference $feature.&lt;SPAN&gt;{expression/expr0}? That syntax doesnt work, but hopefully this is possible and I'm doing it wrong?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 16:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318610#M15939</guid>
      <dc:creator>RobBlash</dc:creator>
      <dc:date>2019-10-25T16:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318611#M15940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can reference existing expressions in the Existing tab of the expression authoring window:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/476635_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2019 21:02:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318611#M15940</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-12-19T21:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318612#M15941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.esri.com/migrated-users/275713"&gt;Peter Klingman&lt;/A&gt;‌ - is there a way to just embed the name of the expression? I'm pretty new at using Arcade Expressions and the online documentation doesn't reference how to embed expressions in another expression.Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2020 17:14:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318612#M15941</guid>
      <dc:creator>NicholeSalinger</dc:creator>
      <dc:date>2020-07-22T17:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318613#M15942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nichole, it is not currently possible to reference the expression by name. You would need to select the existing expression from the right hand menu, and this will insert it into the expression that is currently being authored. For all intents and purposes it is the same as reusing the expression by name, albeit makes the script longer. Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Peter&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 23:16:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318613#M15942</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-07-23T23:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318614#M15943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Peter - I ended up figuring out the expression because the&amp;nbsp;embedded code would not cooperate using the method you described. Thanks though!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2020 18:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/318614#M15943</guid>
      <dc:creator>NicholeSalinger</dc:creator>
      <dc:date>2020-07-28T18:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083598#M41457</link>
      <description>&lt;P&gt;You say that "For all intents and purposes it is the same as using the expression by name"&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using arcade to reference a related table to return a few attributes.&amp;nbsp; By retyping the code instead of referencing an earlier expression, that means I need to do a separate function call for FeatureSetByName and Filter for each different attribute I want to return.&amp;nbsp; For ten attributes, that means ten different returns of my entire dataset which isn't very fast.&amp;nbsp; If I could reference earlier expressions, I could set one of them to the returned featureset that has been filtered and not need to make a new featureset for each attribute.&amp;nbsp; Is storing a featureset in an expression a possibility in arcade?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:54:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083598#M41457</guid>
      <dc:creator>KeithBurdette1</dc:creator>
      <dc:date>2021-07-28T16:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083710#M41467</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/260915"&gt;@KeithBurdette1&lt;/a&gt;&amp;nbsp;- what I mean is that inserting the lines of an existing expression into a new expression will execute the same code as if you were importing/referencing the existing expression. Since Arcade is data-driven and looks at your feature layers, there isn't really the concept of storing a FeatureSet in memory and using it in a different expression without making the call to go and get the features again. In your case, can you make one chained Filter/FeatureSetByName call and return all 10 attributes you need to a single FeatureSet? Then you can use dot or bracket notation to access the attributes you need out of the FeatureSet, which would be stored as a variable available within the scope of that expression. I believe this would only make one server call instead of 10. If you want to post your code here I'm happy to take a look as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Peter&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 20:11:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083710#M41467</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-28T20:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083739#M41471</link>
      <description>&lt;P&gt;Thanks for the reply Peter!&lt;/P&gt;&lt;P&gt;Ultimately, if I want to display all the attributes returned by a FeatureSet, don't I need to have an expression for each individual attribute?&amp;nbsp; Or by chain, do you mean a string that displays all the attributes I want that I could then put in a pop-up?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 21:30:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083739#M41471</guid>
      <dc:creator>KeithBurdette1</dc:creator>
      <dc:date>2021-07-28T21:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade: Can you reference an existing expression in another expression?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083748#M41472</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/260915"&gt;@KeithBurdette1&lt;/a&gt;&amp;nbsp;- By chain I meant use Filter and FeatureSet in the same call to reduce round trips to the server. But you're spot on - to return multiple attributes from the related records, what you can do is create an empty string, loop through the featureSet, and add records to the string. Here is a quick example of both:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var globalId = $feature.GlobalID;
var fset = Filter(FeatureSetByName($map,"RelatedFeatures"), 'RELATEFIELD = @globalId');
var returnString = "";
for (var f in fset) {
    returnString += "Related Record # " + f.NUMBER_RELATED
    returnString += TextFormatting.NewLine
    returnString += f.TEXT_RELATED
    returnString += TextFormatting.NewLine
    returnString += "-----------------"
    returnString += TextFormatting.NewLine
}

return returnString&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Returns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Peter_Klingman_0-1627509071580.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/19592i47872B4B451308ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Peter_Klingman_0-1627509071580.png" alt="Peter_Klingman_0-1627509071580.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Peter&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 21:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-can-you-reference-an-existing-expression-in/m-p/1083748#M41472</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-28T21:52:00Z</dc:date>
    </item>
  </channel>
</rss>

