<?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: How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app? in Experience Builder Custom Widgets</title>
    <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603026#M534</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/677423"&gt;@JeffreyThompson2&lt;/a&gt;&amp;nbsp;, could you please help me in this regards.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Apr 2025 03:58:32 GMT</pubDate>
    <dc:creator>Vara_PrasadM_S</dc:creator>
    <dc:date>2025-04-05T03:58:32Z</dc:date>
    <item>
      <title>How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app?</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1602939#M532</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;In ExpBuilder, in Data tab, I&amp;nbsp; have added a webmap and used it as source for map widget. And in our custom widgets, we are trying to access the datasources of every layer (our webmap has group layers, sub layers, feature layers). However, the datasource objects of all layers are undefined. And DatasourceManagerInstance::datasources has only one object which is datasource of WebMap.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the snippet Im using to retrieve instance of datasource of layers. Always getting the 'Data source object is undefined.'. How can we fix this.&lt;/P&gt;&lt;P&gt;Another point, if we use function '&lt;SPAN&gt;getOrCreateLayerDataSource' on JimuLayerView, its creating a datasource instance but this instance is different and the datasource instance used by OOTB widgets of ExpB for eg., Select widget is different.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Please guide.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;		  const allJimuLayerViews = jimuMapView.getAllJimuLayerViews()
  
          // Ensure all layer views are loaded
          jimuMapView.whenAllJimuLayerViewLoaded().then(() =&amp;gt; {
            // Use DataSourceManager to get existing data sources
            const dataSourceManager = DataSourceManager.getInstance();
            const dataSourcePromises = allJimuLayerViews.map(jlv =&amp;gt; {
              const dataSourceId = jlv.layerDataSourceId; // Assuming layerDataSourceId is available
              if (dataSourceId) {
                return dataSourceManager.getDataSource(dataSourceId);
              } else {
                console.error('Layer DataSource ID not found for layer view:', jlv);
                return Promise.resolve(null); // Return null if dataSourceId is not found
              }
            });
  
            Promise.all(dataSourcePromises).then(dsObjs =&amp;gt; {
              dsObjs.forEach(dsObj =&amp;gt; {
                if (dsObj) {
                  console.error('Data source object is defined.');
                } else {
                  console.error('Data source object is undefined.');
                }
              });
            }).catch(error =&amp;gt; {
              console.error('Error retrieving data sources:', error);
            });
          });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 19:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1602939#M532</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2025-04-04T19:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app?</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603026#M534</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/677423"&gt;@JeffreyThompson2&lt;/a&gt;&amp;nbsp;, could you please help me in this regards.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Apr 2025 03:58:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603026#M534</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2025-04-05T03:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app?</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603030#M535</link>
      <description>&lt;P&gt;It might be because the data sources are created on demand. You could use this method to make sure they're created:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;jimuLayerView.createLayerDataSource() or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DataSourceManager.getInstance()&lt;BR /&gt;.createDataSourceByUseDataSource()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can read about a similar issue I had &lt;A href="https://github.com/Esri/arcgis-experience-builder-sdk-resources/issues/193" target="_self"&gt;here&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And &lt;A href="https://github.com/Party-Pelican/exb-custom-widgets/blob/main/widgets/query-builder/src/runtime/widget.tsx" target="_self"&gt;here&lt;/A&gt; is an example of how I used the 2nd method.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Apr 2025 07:09:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603030#M535</guid>
      <dc:creator>PartyPelican</dc:creator>
      <dc:date>2025-04-05T07:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app?</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603042#M536</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/763368"&gt;@PartyPelican&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;I have implemented your suggested code and its giving me DataSource objects. However, would ExB also used same instances for OOTB widgets? Otherwise, widgets will not be in sync. For eg., if we select features of a layer from OOTB select widget and read those selected features from this instance that we create, if they don't match we will not get the selected features. Could you please guide me further.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Apr 2025 17:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603042#M536</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2025-04-05T17:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do we access datasources of all layers created by ExB and it uses internally through the webmap added to Data tab of the app?</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603549#M539</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/763368"&gt;@PartyPelican&lt;/a&gt;, your sample is working and my code snippet is also working. ExpB is referring to same Datasource object internally. It matched.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 01:41:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/how-do-we-access-datasources-of-all-layers-created/m-p/1603549#M539</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2025-04-08T01:41:21Z</dc:date>
    </item>
  </channel>
</rss>

