<?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: Open widget in Widget Controller in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538237#M14849</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;Yes, you can find the current assigned id in the current configuration of an app, and in it will work, I don't doubt that.&amp;nbsp; However, sometimes when you make a custom widget or action, and you may want to reuse this action or widget in other apps, it becomes important to know how to get that widgetId dynamically, because, that widgetID is assigned at the moment the widget is dragged into the dashboard.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say its assigned widget_32 in one experience that you create.&amp;nbsp; In the next one it could be widget_45.&amp;nbsp; &amp;nbsp;So while technically correct you could 'hard code' the id somewhere and use that and it would work, it would only work in that experience, meaning you have to repeatedly go in and check that assigned ID.&lt;BR /&gt;&lt;BR /&gt;The other reason this could be important, is that if you have settings that get updated during development of a custom widget, or new config options, those config options often necessitate removal of the widget from the experience + saving in order to clear the previous config information, before dragging the updated widget in and then configuring those settings.&amp;nbsp; As I have seen how quickly those IDs can change, in a more complex widget, relying on the assigned ID hard coded somewhere that way, means having to remember checking it every time you have to do that procedure.&lt;BR /&gt;&lt;BR /&gt;Now for a lot of custom widgets, there may be no need to worry about that, just wanted to be clear, cause understanding the reason why I suggested a dynamic way to get it, is that it solves the problem in a specific set of circumstances when developing.&amp;nbsp; I hope that clarifies.&lt;BR /&gt;&lt;BR /&gt;(also in regard to what was going on with my action opening the widget and data not being there, I fixed that by having it poll and wait for the appStoreUpdate to be found, only then could I guarantee it was there in time when the Widget Opens. Because the way react handles state asynchronously you have no way to guarantee that data stored in that way, is available when the next command runs, without providing code to check or wait for it before executing other code which may need it.&amp;nbsp; I was able to resolve that issue, in this manner.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2024 13:04:44 GMT</pubDate>
    <dc:creator>TimWestern</dc:creator>
    <dc:date>2024-09-13T13:04:44Z</dc:date>
    <item>
      <title>Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1102982#M2869</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to programmatically open widget that is in "Widget Controller".&lt;/P&gt;&lt;P&gt;I have tried&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;WidgetManager.getInstance().openWidget(widgetId)&lt;/LI-CODE&gt;&lt;P&gt;and&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const action = appActions.openWidget(widgetId);
getAppStore().dispatch(action);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both attempts opened the widget, but only when the widget had been previously opened.&lt;/P&gt;&lt;P&gt;Is there a way how to open widget that was not yet opened?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;&lt;SPAN&gt;ArcGIS Experience Builder Developer Edition version 1.5.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Matěj.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 07:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1102982#M2869</guid>
      <dc:creator>MatejKutik</dc:creator>
      <dc:date>2021-09-29T07:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1109367#M3026</link>
      <description>&lt;P&gt;I'd also like to know of a solution. I have a widget I would like to have open when the app loads.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 18:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1109367#M3026</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2021-10-20T18:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1110193#M3057</link>
      <description>&lt;P&gt;This is something that was not possible in versions before 1.6.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/experience-builder/sample-code/widgets/control-the-widget-state/" target="_blank"&gt;https://developers.arcgis.com/experience-builder/sample-code/widgets/control-the-widget-state/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 12:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1110193#M3057</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-10-22T12:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1110273#M3060</link>
      <description>&lt;P&gt;Awesome! Thanks for the notice. Did 1.6 come out this week?&lt;BR /&gt;&lt;BR /&gt;Robert do you know how we would tell the widget to open at a certain position within a map view?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1110273#M3060</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2021-10-22T14:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1114004#M3129</link>
      <description>&lt;P&gt;Not have not looked into that yet&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 12:16:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1114004#M3129</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-11-04T12:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1114077#M3130</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/140982"&gt;@MatejKutik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Were you able to use the sample code to open the widget as the application loaded? You mentioned your sample worked but only if the Widget had been opened at least once.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 14:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1114077#M3130</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2021-11-04T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1400741#M11760</link>
      <description>&lt;P&gt;In 1.13 you can load widget and then open it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const widgetManager = WidgetManager.getInstance();
widgetManager.loadWidgetClass(widgetId);
widgetManager.openWidget(widgetId);&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Mar 2024 07:30:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1400741#M11760</guid>
      <dc:creator>AnnaGoldenstein</dc:creator>
      <dc:date>2024-03-26T07:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1537257#M14787</link>
      <description>&lt;P&gt;This code is very close to what I ended up with.&amp;nbsp; There are two problems I ran into.&lt;BR /&gt;&lt;BR /&gt;The first is, there is a difference between the widgetId of the source of the action (event), and the widgetId of the target of the action.&amp;nbsp; I was having some serious troubles getting it to open.&amp;nbsp; One thing I ran into with EXB 1.14 was that Because a widget could be on the screen or in the experience multiple times, it can be tricky to find the right one.&amp;nbsp; Now, when you add them they all get a generic ID in the config.json something like widget_34 (where 34 is conceivably the count of items + 1 that have been added to the experience)&lt;BR /&gt;&lt;BR /&gt;As you may guess, widget_34 is not a very descriptive ID.&amp;nbsp; So I sought out a way to find a widget by its name in the client (not necessarily its uniqueId, but one that's more descriptive and came up with code like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/**
   * Opens the results widget using the dynamically assigned widget ID.
   */
  openResultsWidget = (): void =&amp;gt; {
    // Lookup the dynamically assigned widget ID in the Experience Builder configuration
    // Where widgets is the folder under your-extensions, and your-widget-name is the folder name for the client widget
    const widgetUri = 'widgets/your-widget-name/' 
    const widgets = getAppStore().getState().appConfig.widgets // Get the current app widgets config

    // Find the widget with the specified URI
    const widgetEntry = Object.entries(widgets).find(
      ([, widgetConfig]: [string, any]) =&amp;gt; widgetConfig.uri === widgetUri
    )

    if (!widgetEntry) {
      console.error(`No widget found with URI: ${widgetUri}`)
      return
    }

    const [dynamicWidgetId] = widgetEntry // Extract the dynamically assigned widget ID (e.g., "widget_34")
    console.log(`Found widget ID: ${dynamicWidgetId}`)

    // Check if the widget class is already loaded
    const isClassLoaded = getAppStore().getState().widgetsRuntimeInfo?.[dynamicWidgetId]?.isClassLoaded

    if (!isClassLoaded) {
      // Load the widget class dynamically
      WidgetManager.getInstance()
        .loadWidgetClass(dynamicWidgetId)
        .then(() =&amp;gt; {
          getAppStore().dispatch(appActions.openWidget(dynamicWidgetId))
          console.log(`Widget (${dynamicWidgetId}) opened after loading.`)
        })
        .catch((err) =&amp;gt; {
          console.error('Error loading widget class:', err)
        })
    } else {
      // If already loaded, just open it
      getAppStore().dispatch(appActions.openWidget(dynamicWidgetId))
      console.log(`Widget (${dynamicWidgetId}) opened directly.`)
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Now the other piece I was working on that I don't have a good working snippet for yet, I had designed the custom widget to look into appStore for certain things to be set, or changed and if present or changed, auto load data when opening.&amp;nbsp; For some reason this action can launch before the appStore has the data, and its a timing issue I am already looking into.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 12:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1537257#M14787</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-09-11T12:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1537265#M14788</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/727644"&gt;@TimWestern&lt;/a&gt;&amp;nbsp;The easiest way to find a widget_id is to look in the config.json. Here's how to find a sidebar: Open the config.json file in /server/public/apps/your-application-number/resources/config. Use ctl+F to find the word "Sidebar" and use that widget_id.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 12:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1537265#M14788</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-09-11T12:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538237#M14849</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;Yes, you can find the current assigned id in the current configuration of an app, and in it will work, I don't doubt that.&amp;nbsp; However, sometimes when you make a custom widget or action, and you may want to reuse this action or widget in other apps, it becomes important to know how to get that widgetId dynamically, because, that widgetID is assigned at the moment the widget is dragged into the dashboard.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say its assigned widget_32 in one experience that you create.&amp;nbsp; In the next one it could be widget_45.&amp;nbsp; &amp;nbsp;So while technically correct you could 'hard code' the id somewhere and use that and it would work, it would only work in that experience, meaning you have to repeatedly go in and check that assigned ID.&lt;BR /&gt;&lt;BR /&gt;The other reason this could be important, is that if you have settings that get updated during development of a custom widget, or new config options, those config options often necessitate removal of the widget from the experience + saving in order to clear the previous config information, before dragging the updated widget in and then configuring those settings.&amp;nbsp; As I have seen how quickly those IDs can change, in a more complex widget, relying on the assigned ID hard coded somewhere that way, means having to remember checking it every time you have to do that procedure.&lt;BR /&gt;&lt;BR /&gt;Now for a lot of custom widgets, there may be no need to worry about that, just wanted to be clear, cause understanding the reason why I suggested a dynamic way to get it, is that it solves the problem in a specific set of circumstances when developing.&amp;nbsp; I hope that clarifies.&lt;BR /&gt;&lt;BR /&gt;(also in regard to what was going on with my action opening the widget and data not being there, I fixed that by having it poll and wait for the appStoreUpdate to be found, only then could I guarantee it was there in time when the Widget Opens. Because the way react handles state asynchronously you have no way to guarantee that data stored in that way, is available when the next command runs, without providing code to check or wait for it before executing other code which may need it.&amp;nbsp; I was able to resolve that issue, in this manner.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 13:04:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538237#M14849</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-09-13T13:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538257#M14850</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/727644"&gt;@TimWestern&lt;/a&gt;&amp;nbsp;Everything you have said above is accurate, but it is possible to make it so that the widget_id numbers can be altered in the Settings panel. When I designed my &lt;A href="https://community.esri.com/t5/experience-builder-custom-widgets/identify-for-experience-builder-1-14/ta-p/1480343" target="_self"&gt;Identify Widget&lt;/A&gt;, I built it with the intent that it would be used in a Sidebar Widget and that it would automatically open and close it. But, I made the widget id number a variable, so that it could be used in multiple projects by multiple developers by just finding the number and changing it in the Settings Panel. My code for closing the Sidebar looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;getAppStore().dispatch(appActions.widgetStatePropChange(`widget_${sidebarId}`, 'collapse', false))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 13 Sep 2024 13:17:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538257#M14850</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-09-13T13:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Open widget in Widget Controller</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538262#M14852</link>
      <description>&lt;P&gt;yeah, creating a setting to control that ID could work great too.&amp;nbsp; I think I didn't adopt that for my more complex example in part because I was having issues getting that setting in the action when it was constructed and called from another widget.&amp;nbsp; next time I work on one of these I'll look into that, cause ideally, there are probably a lot of cases where you'd want it to work just like that.&amp;nbsp; Thanks for pointing that out. (Also my approach presumes only one version of the widget on a page, if its used more than once, the code I shared won't get it for all of them)&lt;BR /&gt;&lt;BR /&gt;(IIRC, I was having issues keeping that widgetID known and present if that widget was not currently open and loaded on the screen, it occurred to me later, that saving that ID somewhere with more clear scope (such as to appStore itself) could have solved that also.)&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 13:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/open-widget-in-widget-controller/m-p/1538262#M14852</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-09-13T13:26:21Z</dc:date>
    </item>
  </channel>
</rss>

