How to pass data from weblocks to main page

How to pass data from weblocks to main page

  

Hi Guys,

We are currently doing a project in OutSystems that has weblock inside a List. Please see below picture for the sample output of our project :


What we want to achieve is if all the value in the web block are Pass then then the list item will also be Pass and when one of the value is Fail then the value of the list item will be Fail. 

Thanks in advance for any help and suggestion

Solution

The simplest way is using the Notify server action from (System), the way you set it up is:

When you do all your calculations inside the webBlock you use the Notify action, you pass it a message (for example if all passed you can send "AllPassed".

Then on the parent Web Screen you create an action for the OnNotify event of the webBlock. In this action you need to check the message by using the NotifyGetMessage action, for example in case it is "AllPassed", you update the value of your variable that controls the Hardness Test widget and then refresh the widget.


If you need a more graphical explanation let me know and i'll upload some screenshots.

Solution

Ariel Balasta wrote:

What we want to achieve is if all the value in the web block are Pass then then the list item will also be Pass and when one of the value is Fail then the value of the list item will be Fail. 

Thanks in advance for any help and suggestion

Hi Ariel, you can use the IF Widget and give the Value of Pass for the True branch and Fail for the False branch(in the case you're storing this information on some entity), and pass the condition for the widget, but also you need to pass the information with the  Notify to the parent of the web block and there you call the logic that I said

Hope I could help you!

Cheers.

Hi Ariel,

For Web Apps, there's no way for a Screen or parent Web Block to directly get values out of a child Web Block (as you probably already know). Like Afonso already said, a Web Block can send data to its parent Screen or parent Web Block using the Notify Action. Since there's only a single Text that can be passed, there are various options how to use that.

The first option is that if the Widget has a single status e.g. "fail" or "pass", each time the user makes changes to the Web Block data, you send the appropriate status via the Notify parameter (I'd keep it simpel, perhaps "F" or "P", or "True" and "False" or whatever). In the parent Screen you take the appropriate action (setting a status, updating the Screen via an Ajax Refresh).

The second option is that you don't send any status back, but get the status via a query in the parent Screen. Iirc, the Current of the list is available in the OnNotify, so you know which row has sent the notification.

A third option is to send the entire (or applicable parts of the) dataset of the Web Block via the Notify. You can use the built in Statements JSON Serialize and JSON Deserialize for that. In the parent Screen you can then calculate the status based on the data.

Hi Ariel,

Check also the topic Propagate Changes From a Block to the Parent in OutSystems documentation.

Hope it helps!

Afonso Aguas wrote:

The simplest way is using the Notify server action from (System), the way you set it up is:

When you do all your calculations inside the webBlock you use the Notify action, you pass it a message (for example if all passed you can send "AllPassed".

Then on the parent Web Screen you create an action for the OnNotify event of the webBlock. In this action you need to check the message by using the NotifyGetMessage action, for example in case it is "AllPassed", you update the value of your variable that controls the Hardness Test widget and then refresh the widget.


If you need a more graphical explanation let me know and i'll upload some screenshots.


Thanks Afonso, it works. Thanks all for your reply and suggestion.