Passing data from multiple web blocks on a single page

I have a page that is using 4-5 web blocks to submit a form. Right now, all of the web blocks refer to the same Entity but just hold different sections of that single entity.

My entity is called IdentityAndContact: I have 5 web blocks: address, name, contact, nationality, group which all contain some attributes of the IdentityAndContact entity. Each web block has a form that requires user input:

e.g. 

I also have a "Save" Web block that contains the Save button to commit to database:


My question is, how would I be able to submit data from all 5 web blocks to one instance of the "IdentityAndContact" record by using that one "Save" button from the "Save" web block. I do not want to submit each web block individually but rather have a single method that commits all 5 web blocks at once.

Solution

Hi Jason,

If you want everything to be covered by that one "Save" button inside yet another Web Block, I'd suggest you look into the Event System component to share information between Web Blocks.

I have a hard time understanding why you need to split a form in those web blocks, can you explain why you took that approach? A simple Form directly with inputs and buttons seems to be a lot more practical...

Solution

Jorge Martins wrote:

Hi Jason,

If you want everything to be covered by that one "Save" button inside yet another Web Block, I'd suggest you look into the Event System component to share information between Web Blocks.

I have a hard time understanding why you need to split a form in those web blocks, can you explain why you took that approach? A simple Form directly with inputs and buttons seems to be a lot more practical...


Hi Jorge,


Thanks for the reply. There are a few reasons, but the main reason is that the sections I've split the form into are reused by other pages in the application. E.g. The "Name" block is used multiple times in other pages/applications. The "IdentityAndContact" record also has about 70 attributes which I felt would clutter a single web block.


I understand the reuse reasons, but validations don't mix well with web blocks (the Event System component helps a lot there actually), so more often than not I end up not using web blocks to reuse parts of Forms, or I trigger events to pass the data to the outer form, so there's a single Form to be submitted in the end.

What about the Button's web block? The logic surely changes a lot depending on the section web blocks you are using, no? is it really reusable?

Jason Zhao wrote:

I have a page that is using 4-5 web blocks to submit a form. Right now, all of the web blocks refer to the same Entity but just hold different sections of that single entity.

My entity is called IdentityAndContact: I have 5 web blocks: address, name, contact, nationality, group which all contain some attributes of the IdentityAndContact entity. Each web block has a form that requires user input:

e.g. 

I also have a "Save" Web block that contains the Save button to commit to database:


My question is, how would I be able to submit data from all 5 web blocks to one instance of the "IdentityAndContact" record by using that one "Save" button from the "Save" web block. I do not want to submit each web block individually but rather have a single method that commits all 5 web blocks at once.


Hi Jason,

If you are really need reusable thing as per your above scenario then you can only do whatever I have done in attached OML..this is the only way you can do it. OR you can change your Screen Design approach.



Screen Shot

Hi Jason,

Please have a look at this post.

https://www.outsystems.com/forums/discussion/32511/call-webblocks-save-action-from-parent-screen/

Thanks and Regards,

Suraj Borade

Hi Jason,

In addition to what has already been said, in Platform version 11 you can fire events from Web Blocks to the Screen containing them. Thus you can pass any update data (via an OnChange) the Screen, so that the Screen is ultimately the source of all the data that needs to be saved. When the Save button is pressed, you can send another event, and the Screen can then save the data to the single record.

Note that I don't find this approach ideal, but given the monstrous data model and the need for several Web Blocks, I think that's the best approach (without using Forge components like Events).

Kilian Hekhuis wrote:

Hi Jason,

In addition to what has already been said, in Platform version 11 you can fire events from Web Blocks to the Screen containing them. Thus you can pass any update data (via an OnChange) the Screen, so that the Screen is ultimately the source of all the data that needs to be saved. When the Save button is pressed, you can send another event, and the Screen can then save the data to the single record.

Note that I don't find this approach ideal, but given the monstrous data model and the need for several Web Blocks, I think that's the best approach (without using Forge components like Events).


Hi Sir,

Can you please provide the links for the same?

Thanks and Regards,

Suraj Borade

Hi Suraj,

I'm not sure I understand what you mean? Documentation about Events can be found here, an example of sharing data between Web Blocks, and between the Screen and Web Blocks can be found here.

Kilian Hekhuis wrote:

Hi Jason,

In addition to what has already been said, in Platform version 11 you can fire events from Web Blocks to the Screen containing them. Thus you can pass any update data (via an OnChange) the Screen, so that the Screen is ultimately the source of all the data that needs to be saved. When the Save button is pressed, you can send another event, and the Screen can then save the data to the single record.

Note that I don't find this approach ideal, but given the monstrous data model and the need for several Web Blocks, I think that's the best approach (without using Forge components like Events).

Thanks OS11 for this update


Kilian Hekhuis wrote:

Hi Suraj,

I'm not sure I understand what you mean? Documentation about Events can be found here, an example of sharing data between Web Blocks, and between the Screen and Web Blocks can be found here.

I was asking for the documentation of same. Thanks.!!