Dropdown method not working from Event Handler (VIDEO)

Hello,

In additional to what Tess was saying:

The first issue is you have multiple event handlers and they are running asynchronously. However, your operation is not...new data is needed before updating the dropdown to the last value. Hence, the attempt with setTimeout.

Second issue is <query>.data is not immediately available after .trigger() finished during runtime, you can take a look at this old post back in 2021 to understand: Await for a query to finish - #7 by minijohn

I was able to get it working using the solution in the old post. Note: replace the contents inside setvalue with your Math.max(...) but use the const variable instead of VendorTypesList.data.

modal1.close();

const ddData = await new Promise((resolve) => {
  loadData.trigger({
    onSuccess: (data) => {
      resolve(data);
    },
  });
});

select1.setValue(ddData.value[ddData.value.length-1]);

Hope that'll help.

2 Likes