Disable button element while waiting for API call

Hi all,
I have a workflow that call external api. There are times when it takes a few seconds to load the data from API. What I would like to do is to disable a button to prevent a user from clicking a button until the API call is completed.

I couldn’t find an option to disable an element from a workflow. And I want to enable it again after that (perhaps after 5 seconds or something).

any thought on this?

1 Like

Disabling an element can be done in the “Conditional” tab. See screenshot - “This element isn’t clickable”. Disregard the “This Button is hovered”… In short, you should be able to set a condition that while your API call is working, disable this button.

As for how to determine when the API call is working and when done, there are other topics in this forum better suited for that… In short, you’ll need to determine how much data you are expecting from the API call and then cross reference that with your database.

Example: I have a tickets database - It holds ticket name and date. For this example, let’s say I have 10 tickets in the database. My API pulls new tickets from, say, Zendesk. Before I make my API call, I count how many new tickets are coming from ZenDesk using Bubble’s “:count” ability and then how many tickets I have in my current ticket database, also using “:count”. Let’s say Zendesk has 40 new tickets. The database, as stated before, has 10. So you can set a condition on your button that you want to disable for "If the count in my database is less than 50 (Zendesk + Current Tickets), then DISABLE. " This may require another button since this condition is always live… For that, I’ll leave to you to figure out. Finally, the API will run… Once the database has 50 tickets, it should re-enable automatically.

Hopefully that gives you enough direction to move forward - I don’t think that’s every single detail you need to achieve your goal but is a good starting point. Let me know if it works out.

This topic was automatically closed after 70 days. New replies are no longer allowed.