<?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: Url parameters in widgets in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357314#M9710</link>
    <description>&lt;P&gt;As it happens I've been working on a widget that does the first part of this pretty easily. I don't know what kind of source you might be using, but consider a method like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const getServiceUrl = (dataSourceId): Promise&amp;lt;string&amp;gt; =&amp;gt; {
        return new Promise((resolve) =&amp;gt; {
            const checkDataSourceManager = () =&amp;gt; {
                const dataSourceManager = DataSourceManager.getInstance();

                if(dataSourceManager) {
                    const dataSourceArray = dataSourceManager.getDataSourcesAsArray();
                    const selectedDataSource = dataSourceArray.find(ds =&amp;gt; ds.id === dataSourceId);
                    //const dataSrcJson = dataSourceManager.getDataSource(dataSourceId).getDataSourceJson();
                    const dataSrcJson = selectedDataSource.getDataSourceJson();
                    const dataSourceURL = dataSrcJson?.url + queryString;
                    resolve(dataSourceURL);
                } else {
                    setTimeout(checkDataSourceManager, 100); // Check again after a short delay
                }
            };

            checkDataSourceManager();
        });
    };
	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This uses a dataSourceID that is already added in the Data section&lt;/LI&gt;&lt;LI&gt;That dataSourceID is then used to find the specific source in the array returned from getDatSourcesAsArray.&lt;/LI&gt;&lt;LI&gt;you can then get the urlFrom a DataSource and tack on a queryString in my case it's a querystring with a token added onto it, but depending on your context and access permissions you may not need that. but the query will look like the url path you would browse to through a browser for a Feature when queried.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;That will then resolve and return some response object that in its body would have the query in whatever format it might need to be in.&amp;nbsp; For Example json.&lt;/LI&gt;&lt;LI&gt;Note that the path is actually a RESTful query that can return a set. you can always do additional filtering at runtime in JavaScript if needed.&lt;BR /&gt;&lt;BR /&gt;This is just one way to do this with JS/TypeScript.&amp;nbsp; There may be others.&amp;nbsp; For example, if you can get access to the actual FeatureLayer then you can run a query on it directly without creating the query path as a url structure.&amp;nbsp; example here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-basic/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-basic/&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Wed, 06 Dec 2023 12:57:07 GMT</pubDate>
    <dc:creator>TimWestern</dc:creator>
    <dc:date>2023-12-06T12:57:07Z</dc:date>
    <item>
      <title>Url parameters in widgets</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357297#M9708</link>
      <description>&lt;P&gt;I'm new to experience builder and I'm building a new project my question would be is&amp;nbsp;it possible to create custom widget in experience builder that can read and fetch url parameters and then filter based on those parameters?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 11:58:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357297#M9708</guid>
      <dc:creator>ErsiLover</dc:creator>
      <dc:date>2023-12-06T11:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Url parameters in widgets</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357314#M9710</link>
      <description>&lt;P&gt;As it happens I've been working on a widget that does the first part of this pretty easily. I don't know what kind of source you might be using, but consider a method like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const getServiceUrl = (dataSourceId): Promise&amp;lt;string&amp;gt; =&amp;gt; {
        return new Promise((resolve) =&amp;gt; {
            const checkDataSourceManager = () =&amp;gt; {
                const dataSourceManager = DataSourceManager.getInstance();

                if(dataSourceManager) {
                    const dataSourceArray = dataSourceManager.getDataSourcesAsArray();
                    const selectedDataSource = dataSourceArray.find(ds =&amp;gt; ds.id === dataSourceId);
                    //const dataSrcJson = dataSourceManager.getDataSource(dataSourceId).getDataSourceJson();
                    const dataSrcJson = selectedDataSource.getDataSourceJson();
                    const dataSourceURL = dataSrcJson?.url + queryString;
                    resolve(dataSourceURL);
                } else {
                    setTimeout(checkDataSourceManager, 100); // Check again after a short delay
                }
            };

            checkDataSourceManager();
        });
    };
	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This uses a dataSourceID that is already added in the Data section&lt;/LI&gt;&lt;LI&gt;That dataSourceID is then used to find the specific source in the array returned from getDatSourcesAsArray.&lt;/LI&gt;&lt;LI&gt;you can then get the urlFrom a DataSource and tack on a queryString in my case it's a querystring with a token added onto it, but depending on your context and access permissions you may not need that. but the query will look like the url path you would browse to through a browser for a Feature when queried.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;That will then resolve and return some response object that in its body would have the query in whatever format it might need to be in.&amp;nbsp; For Example json.&lt;/LI&gt;&lt;LI&gt;Note that the path is actually a RESTful query that can return a set. you can always do additional filtering at runtime in JavaScript if needed.&lt;BR /&gt;&lt;BR /&gt;This is just one way to do this with JS/TypeScript.&amp;nbsp; There may be others.&amp;nbsp; For example, if you can get access to the actual FeatureLayer then you can run a query on it directly without creating the query path as a url structure.&amp;nbsp; example here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-basic/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-basic/&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 06 Dec 2023 12:57:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357314#M9710</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2023-12-06T12:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Url parameters in widgets</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357358#M9713</link>
      <description>&lt;P&gt;Thank you for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 14:31:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357358#M9713</guid>
      <dc:creator>ErsiLover</dc:creator>
      <dc:date>2023-12-06T14:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Url parameters in widgets</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357917#M9745</link>
      <description>&lt;P&gt;If you are looking to get an arbitrary URL parameter, not necessarily a data source. You could use URLSearchParams.&lt;/P&gt;&lt;P&gt;Full explanation with a starter widget and an example using it to start a query &lt;A href="https://community.esri.com/t5/experience-builder-tips-and-tricks/starter-widget-for-getting-information-from-a-url/ta-p/1354035" target="_self"&gt;here&lt;/A&gt;, along with many more Experience Builder tips.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 13:31:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/url-parameters-in-widgets/m-p/1357917#M9745</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-12-07T13:31:48Z</dc:date>
    </item>
  </channel>
</rss>

