<?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: Pass url parameter to an Arcade script? in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223276#M6913</link>
    <description>&lt;P&gt;Instant Apps can populate a separate pane ('Sidebar' for example) which provides a similar appearance to what I'm trying to accomplish with a dashboard, but the url parameter options seem more limited with Instant Apps.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 12:52:10 GMT</pubDate>
    <dc:creator>RandyMcGregor3</dc:creator>
    <dc:date>2022-10-19T12:52:10Z</dc:date>
    <item>
      <title>Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1222765#M6905</link>
      <description>&lt;P&gt;I need to populate a details pane based on information that is available in a parameter I have set up in a dashboard:&lt;/P&gt;&lt;P&gt;https:/&amp;lt;app url&amp;gt;#p1=ABC123&lt;/P&gt;&lt;P&gt;The parameter value contains information. So, if it starts with 'ABC,' then I want one layer to populate the detail pane. If it starts with 'CDE' I want a different layer, etc...&lt;/P&gt;&lt;P&gt;I tried:&amp;nbsp;&lt;/P&gt;&lt;P&gt;if(p1 == 'ABC123') {&lt;/P&gt;&lt;P&gt;fs = findPortalItembyID(...)&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;And got an error. It did not recognize 'p1' (the parameter name). Is it possible for Arcade to get this information from the url, or is that out of bounds?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 12:18:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1222765#M6905</guid>
      <dc:creator>RandyMcGregor3</dc:creator>
      <dc:date>2022-10-18T12:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223044#M6909</link>
      <description>&lt;P&gt;Wow, Randy (who I don't know) had the exact same question I did only 8 hours ago. I'm not seeing a way to do this, can someone at Esri point us in the right direction.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 20:44:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223044#M6909</guid>
      <dc:creator>ChristopherEby2</dc:creator>
      <dc:date>2022-10-18T20:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223134#M6910</link>
      <description>&lt;P&gt;As far as I know, that sort of thing is, as you put it, "out of bounds". Or to put it in a developer way, "out of scope". The Arcade expression just can't zoom out far enough to see that sort of thing.&lt;/P&gt;&lt;P&gt;Now, there is probably a way to do this with a Data Expression, but it depends on what your layers are like. Do they have any fields in common?&lt;/P&gt;&lt;P&gt;Here's the general idea:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Pull all relevant layers into a Data Expression using a series of &lt;STRONG&gt;FeatureSetByPortalItem&lt;/STRONG&gt; functions.&lt;/LI&gt;&lt;LI&gt;Merge all your FeatureSets into one massive set, including the source layer's identifier as its own field.&lt;/LI&gt;&lt;LI&gt;Have the URL parameter filter your layer using the newly calculated identifier.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Specific code examples would probably need more details. Is the details widget set to show a specific feature in each layer, or will it be configured to show multiple features, and your URL parameter just filters the available set?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 01:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223134#M6910</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-19T01:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223271#M6911</link>
      <description>&lt;P&gt;Thank you Josh. That is as I feared.&lt;/P&gt;&lt;P&gt;I actually had considered trying to merge all inputs but they have different schemas and the field mapping would be a nightmare. I only need information for a single feature to populate the details pane, but the feature in question could be from any of several layers.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223271#M6911</guid>
      <dc:creator>RandyMcGregor3</dc:creator>
      <dc:date>2022-10-19T12:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223274#M6912</link>
      <description>&lt;P&gt;Great minds! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Would be nice if ESRI could allow Arcade to 'see' url parameters.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:46:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223274#M6912</guid>
      <dc:creator>RandyMcGregor3</dc:creator>
      <dc:date>2022-10-19T12:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223276#M6913</link>
      <description>&lt;P&gt;Instant Apps can populate a separate pane ('Sidebar' for example) which provides a similar appearance to what I'm trying to accomplish with a dashboard, but the url parameter options seem more limited with Instant Apps.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223276#M6913</guid>
      <dc:creator>RandyMcGregor3</dc:creator>
      <dc:date>2022-10-19T12:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223328#M6914</link>
      <description>&lt;P&gt;Well, you might be able to get away with an expression that outputs a FeatureSet with two fields:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The layer ID&lt;/LI&gt;&lt;LI&gt;All the attributes you want displayed, listed in the format &lt;STRONG&gt;`{"field_1":"value_1","field_2":"value_2"...}`&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The catch here is that a &lt;EM&gt;Details &lt;/EM&gt;widget has no additional capabilities to work with the data, it only displays it. A &lt;EM&gt;List&lt;/EM&gt;, on the other hand, will give you access to Advanced Formatting.&lt;/P&gt;&lt;P&gt;You could have a list, then use Advanced Formatting to take that second field with the long string in it, and pass that into &lt;STRONG&gt;Dictionary&lt;/STRONG&gt;. The resulting object could then be iterated over and used to build a table in HTML.&lt;/P&gt;&lt;P&gt;It's complicated, but the end result could look similar to a Details panel, and provided your URL parameter was filtering the data on the way in, the list would only show the 1 feature you needed.&lt;/P&gt;&lt;P&gt;Just to demonstrate the concept, here's a sample FeatureSet:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSet(Text(
    {
        fields: [
            {name: 'the_layer', type: 'esriFieldTypeString'},
            {name: 'the_attributes', type: 'esriFieldTypeString'}
        ],
        geometryType: '',
        features: [
            {
                attributes: {
                    the_layer: 'ABC',
                    the_attributes: `{"this_field":"some_value", "another_field":4}`
                }
            },
            {
                attributes: {
                    the_layer: 'DEF',
                    the_attributes: `{"third_field":"different_value", "a_float":1.5}`
                }
            }]
    }))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that my two "layer" features have completely different fields and values in their &lt;STRONG&gt;the_attributes&lt;/STRONG&gt; string. I'm using backtick strings, because in a &lt;EM&gt;real &lt;/EM&gt;application of this, the values would be populated by something like ${feature.attribute}.&lt;/P&gt;&lt;P&gt;Bringing this into a list, we can then use this expression in our Advanced Formatting:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var dict = Dictionary($datapoint["the_attributes"])

var tbl_rows = []

for (var key in dict){
    Push(
        tbl_rows,
        `&amp;lt;tr&amp;gt;&amp;lt;td style="width:50%; border:2px solid white"&amp;gt;${key}&amp;lt;/td&amp;gt;&amp;lt;td style="border:2px solid white;"&amp;gt;${dict[key]}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;`
    )
}

var tbl_html = `&amp;lt;table style="width:100%; border-collapse:collapse;"&amp;gt;${Concatenate(tbl_rows, '')}&amp;lt;/table&amp;gt;`

return {
   attributes: {
    attr_dict: Text(dict),
    table: tbl_html
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which gives you this (I have the layer ID and the raw JSON shown, too):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1666188809521.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/53946i191F5E94AF11587C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1666188809521.png" alt="jcarlson_0-1666188809521.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With just a bit of tweaking to the CSS styling, there's no reason you couldn't get a tabular display of varying input schemas into a single widget.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:14:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223328#M6914</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-19T14:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Pass url parameter to an Arcade script?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223763#M6919</link>
      <description>&lt;P&gt;This looks very interesting, thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 12:54:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/pass-url-parameter-to-an-arcade-script/m-p/1223763#M6919</guid>
      <dc:creator>RandyMcGregor3</dc:creator>
      <dc:date>2022-10-20T12:54:16Z</dc:date>
    </item>
  </channel>
</rss>

