Preventing duplicate action calls

In every single application you work on, you must apply some kind of mechanism to prevent the user to click twice in the same button when performing a single action.

If you ignore this fact, your application can behave unexpected and your data become corrupted.

But why this is a problem?

  • Users are used to do double clicks, so you might expect that they will also double click on buttons or links;
  • Users expect immediate feedback and some actions might take seconds to execute. If you don’t prevent the user to click the button again, he/she eventually will;

Let’s see an example:

As you can see:

  1. I clicked the button, which triggered the company create action;
  2. I didn’t receive any feedback, so I clicked the button again before receiving the answer from the server;
  3. When the second request to the server was executed, the Company was already created and the application returned the respective error;
  4. At last, we receive the response from the first call to the server with a success message;

This is obviously wrong and a bad user experience.


What can we do to prevent this?

What I usually do is to use a local control variable named IsBusy (boolean):

and, in each button/link that performs any action that changes data, I force all buttons/links to be disabled when IsBusy = TRUE:

then, in each action that changes data, I set IsBusy = True before executing the action and IsBusy = False after executing the action:

Let’s see it in action…

As you can see:

  1. I clicked the button, and the button is immediately disabled;
  2. As the button is disabled, I cannot click it again before receiving the answer from the server;

This is obviously a better user experience and prevents unexpected results from the action being triggered more than once.


You can test the working example here: https://tiagomlcdias.outsystemscloud.com/BlogArticles/PreventingDuplicateActionCalls


Users be like: ‘If one click doesn’t work, surely two in rapid succession will confuse the computer into submission.’ 😄🖱️