Save data. Action that will save, inside screen or block?
Question

Hi,

I have a block and i am using it inside a screen.

I have inside the block the button SAVE.

Do I just create an event for the save button inside the block and the action that will save inside the screen or vise versa?

Thank you in advance.

Kind regards,

Pedro Boffa

Solution

Hello,

I have Created a Oml, To explain it, Please have a look, I hope this helps.
Link - Sample Screen

Thanks & Regards
Tousif

Sample_Block_Event.oml

Solution

Hi Pedro,

i think that there is no rule of thumb when to perform the action in the block or in its parent screen. Strongly depends on your use case and lets say the reusability of your blocks. My rule of thumb is "Saves are performed by the owner of the data" <- that can be a screen or a block.

Example

Lets say you have a task application which just stores user assigned tasks and allows users to read and update task items. Now you create some other applications and you want to allow users to create task items on various screens. In that case it would make sense to create a core widget module for your task application which contains a block with a form to create a task. The block would of course also contain the save operation and expose an OnSaved event (with or without the saved task). The block can than be added to your various applications and your consuming application do not have to implement the save logic. All is encapsulated in your core widget/block.

The same is of course true for reusing a block in various screens in a single application.

Best

Stefan

Thank you all for your time and help.

Solution

I think you should create event in the block and action in the screen. Because on save you may have some extra apart from the data get from block. Also on click on save you may also need some navigation or alerts. So it will work in all the cases.

regards

Solution

Hey @Pedro Boffa ,
The event is used to share data from web block to parent screen, if you want to return something from web block to screen that time you can use event in web block and create handler in parent screen.

For more details please follow given link.

Blocks and Events Course - Training | OutSystems 

Passing Data from Web Block to Parent Screen Without Refreshing Parent Screen | OutSystems 

Screen Lifecycle Course - Training | OutSystems 

Welcome to OutSystems documentation - OutSystems 

Hope you will understand.

Thanks

Yogesh

Solution

I think you should create event in the block and action in the screen. Because on save you may have some extra apart from the data get from block. Also on click on save you may also need some navigation or alerts. So it will work in all the cases.

regards

Solution

Hey @Pedro Boffa ,
The event is used to share data from web block to parent screen, if you want to return something from web block to screen that time you can use event in web block and create handler in parent screen.

For more details please follow given link.

Blocks and Events Course - Training | OutSystems 

Passing Data from Web Block to Parent Screen Without Refreshing Parent Screen | OutSystems 

Screen Lifecycle Course - Training | OutSystems 

Welcome to OutSystems documentation - OutSystems 

Hope you will understand.

Thanks

Yogesh

Solution

Hello,

I have Created a Oml, To explain it, Please have a look, I hope this helps.
Link - Sample Screen

Thanks & Regards
Tousif

Sample_Block_Event.oml

Solution

Hi Pedro,

i think that there is no rule of thumb when to perform the action in the block or in its parent screen. Strongly depends on your use case and lets say the reusability of your blocks. My rule of thumb is "Saves are performed by the owner of the data" <- that can be a screen or a block.

Example

Lets say you have a task application which just stores user assigned tasks and allows users to read and update task items. Now you create some other applications and you want to allow users to create task items on various screens. In that case it would make sense to create a core widget module for your task application which contains a block with a form to create a task. The block would of course also contain the save operation and expose an OnSaved event (with or without the saved task). The block can than be added to your various applications and your consuming application do not have to implement the save logic. All is encapsulated in your core widget/block.

The same is of course true for reusing a block in various screens in a single application.

Best

Stefan

Thank you all for your time and help.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.