Disable/enable Submit button on calling web service

Hi,

I have a scenario where on a screen I am hitting a button and once it is clicked I am making a web service call and the output is returned/displayed on the same screen.

The requirement is to disable the button once you click it and the system should wait until the web service response is received. Once the response is received the button should be enabled back.

The current behavior is that button can only be disabled only after the response is received. The web service call is tried both at interface and process level.

Any suggestions would be helpful to achieve this!

  Discussion posts and replies are publicly visible

  • Hi Gajapathy,

    Hope you are calling the web service after the click of the button. My suggestion will be add a variable let say local!buttonVisibility and make it as false() when you click it at first, then call the weservice. Once the weservice call is success then again enable the buttonVisibility.

  • Thanks Dinesh! 

    I even tried that. The issue is that only after the web service response is received(once the page loads and completes) the local variable is updated to false.

    I need to update that variable to false the second I click the button. 

  • In the saveInto: of your button you can break up the processing into steps by using a list of a!save() functions. Your first can set the local!variable that controls the button's enabled status (better to keep it visible but disabled rather than hide it imo), and then in the next a!save() make the call to the web service. You can then change the value of the local!variable as the result of the data being retrieved by declaring that local!variable as an a!refreshVariable(), and alter its value based upon the content of the variable that holds the web service response in. SO, the steps should be something like this:

    1. button is clicked
    2. in the saveInto: the first a!save() saves true() to a local!variable that is used to set the button's disabled attribute (let's call the variable local!isButtonDisabled)
    3. in the saveInto: the second a!save() makes the call to the web service
    4. the web service response places data into a local!variable (let's call that local!webServiceResponse)
    5. local!isButtonDisabled is defined as an a!refreshVariable(), with its refresh triggered by a change to the value of local!webServiceResponse, setting the value to false
  • Hi Burchell,

    I tried with your steps, but the problem is that the local!isButtonDisabled value is changed to true only after the web service response is received (or) the local!webServiceResponse has some value.

    Usually the Integration call that I am doing takes 4 to 5 seconds to get back the response and update the variable.

    Till that time the button is still enabled. Only after the response is received the value of local!isButtonDisabled is changed to true and the button is disabled.

    Ideally I need this variable's value to be changed as soon as the button is clicked so that there is no option for the user to click it again until the response is received (till that 4 to 5 secs time frame).