DropDown Control: Determine when Excel fetch completes?


In the Public Web Forms DropDown control linked to an Excel data source, is there a way to determine when the data fetch is complete? I need a way to determine when data has arrived, or if there is no data.

I can do this if the spreadsheet contains data:

    let list = fd.field('OrgsLookup').widget.dataSource.data();
    if (typeof list[0] == 'undefined') { 
        // recursive setTimeout loop here 
    } else {
       // got some data to work with

But if the data source is legitimately empty, this check fails. It would be great if I could register a callback or something to know when the fetch is complete.


Hello @chs-web,

You can use this code to make sure the external data is loaded:

   fd.field('DropDown1').$on('ready', ()=>{

Oh excellent, thank you.

I have two more questions:

  1. I am needing to use a relatively short cache duration for the control. I currently have it set to 30 seconds rather than the default of 600. Is there a minimum valid caching value?

  2. Is there a way to force the control to refresh on a form reload, even if the cache duration has not expired?

Thank you in advance.

Edit: I should explain that the form posts data to our SharePoint site. We want to retrieve the most recent data into the dropdown as soon as it is available after our flow has run on the back-end. Hence, the desire to force a refresh or minimize caching.

Edit 2: Ah, nevermind. I was able to empirically test this, and it seems I can use a cache value as small as 1 without issue.

FYI, the jQuery 'ready' handler never fires if the control's cache has not expired when the form is reloaded. But if we set a minimal cache value to ensure the control repopulates on each form reload, this logic works for us.

Thank you!

1 Like