Call webblock's save action from parent screen

Call webblock's save action from parent screen

  

Hello Community,

Please remind me how to call webblock's Save action from parent screen's Save action.

I have one web screen and it has 2 web blocks. So when I am clicking Save from the screen, save actions of both web blocks should be clicked.

Thanks and Regards,

Suraj Borade

Hi Suraj, 

You can't do that out of the box. You may have luck with the event systems component.

Hi sir,

I remember that I have implemented this behaviour or close to this in the past but not getting how I did that.

Hello Suraj

As Kilian said, what OutSystems has built-in is the complete opposite of what you are trying to achieve

To do what you want, I would suggest JavaScript to auto-click the two buttons inside the WebBlock

You have to name both buttons, and, in the action called by the 'parent' button you should use a RunJavaScript action with something like

document.getElementById('yourLinkID').click();

I'm not totally sure this will work because the two buttons aren't directly on the screen but in two embedded webblocks, but it's worth the shot

Let me know if this worked out or if you have any issues doing this

Regards,

Ângelo

Solution

Hi Suraj,

Complementing on what Ângelo has said:

  • Add a hidden button in each of the web blocks (bound to the Screen action that you want to execute).
  • Give each of those buttons a different class in the Style Classes of the buttons (you have to use classes because you do not know the Id of that button in the parent screen).
  • In the button of the screen run something like this on the onclick extended properties:
$('.classButton1').click(); $('.classButton2').click();

That should be it.

Cheers,

José

Solution

Hi Suraj, 

Just a reminder that in the above solutions you might have some problems handling exceptions. If the second click on the save button raise an exception you won't recover from the first save without additional logic.

I don't see any other / perfect solution also... 

Hey thanks everybody.

Angelo and Jose your solution worked. In the past I had done this with Javascript as suggested by Angelo but now I improved it to use jQuery.

Andre: Exception handling is out of reach now and we don't care but thanks for the suggestion and I will consider that in the future.

I am attaching the oml here if someone needs that in the future.

For future reference, please note that in above oml, I haven't hidden buttons from the web blocks. You need to hide it.