922
Views
2
Comments
Solved
[Events] get data from block to parent screen
Question

I initialize it by creating a list with two empty records.

In the web block I have the form referring to a single record.



When saving, I need to return both records (which are lists with a single record) in a list and display the data of each of them in a message.


In case you get confused, the OML is pretty small, just parent screen and block. I've wasted hours trying to solve this, any help is welcome!

OML.oml
2020-05-07 18-53-00
Rui Barradas
 
MVP
Solution

Hello Turta,

Hope you're doing well.

So I was checking your code and I found out a couple things, let me share them with you.


If you want to pass data between the Block and Parent Screen, you should indeed use Events.

However, you're triggering your event SetData in OnParamatersChanged action. But OnParametersChanged is an event that is only triggered when the input values of the Block change.

Since you're always passing the value True in the Boolean input, this action OnParametersChanged is never triggered (because input values are not changing), that's why the SetData event is not triggering as well.


Anyway, my suggestion is that you use the OnChange events associated to the inputs of your form to trigger the SetData event. Everytime there is a change in your form, you call an action (let's call it OnChangeInputs) and you trigger the SetData event in this action:


OnChangeInputs client action:


Back to your parent Screen, you need to have an Handler for this Block's event, which you have: SalvarOnClick.

These changes should trigger this action, where you can perform the logic that you pretend.


OML follows in attachment. Please consider that I removed some unnecessary things like the IsSave variable, Boolean input and OnParametersChanged event.


Hope that this helps you!


Kind regards,

Rui Barradas

OML.oml
2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Turta,

In addition to Rui's response, a slight different solution would be..

Required Code Changes:

  • ListClear node in the Parent screen Data Source action is not required
  • Introduce a FormRecord variable as the Block input parameter, and associate it with the Form input widgets
  • Block IsSave input parameter is not required
  • Block OnParametersChanges event is not required
  • Define a Block > Input onblur event to pass the current scope Form record value change to the screen
  • In the screen - Block SetDataHandler client action flow, replace the the Screen FormList current row record value with the handler input parameter Form record value.

Note that you will only see the last record as the Feedback message, as it is called in a For Loop. I guess, the reason for using the Feedback message in your case, is to confirm the changes in the Local Screen List variable value w.r.t the block record changes?!

Demo Screen: ParentScreen

Refer to the attached oml


I hope this helps you!


Kind regards,

Benjith Sam

OML.oml
2020-05-07 18-53-00
Rui Barradas
 
MVP
Solution

Hello Turta,

Hope you're doing well.

So I was checking your code and I found out a couple things, let me share them with you.


If you want to pass data between the Block and Parent Screen, you should indeed use Events.

However, you're triggering your event SetData in OnParamatersChanged action. But OnParametersChanged is an event that is only triggered when the input values of the Block change.

Since you're always passing the value True in the Boolean input, this action OnParametersChanged is never triggered (because input values are not changing), that's why the SetData event is not triggering as well.


Anyway, my suggestion is that you use the OnChange events associated to the inputs of your form to trigger the SetData event. Everytime there is a change in your form, you call an action (let's call it OnChangeInputs) and you trigger the SetData event in this action:


OnChangeInputs client action:


Back to your parent Screen, you need to have an Handler for this Block's event, which you have: SalvarOnClick.

These changes should trigger this action, where you can perform the logic that you pretend.


OML follows in attachment. Please consider that I removed some unnecessary things like the IsSave variable, Boolean input and OnParametersChanged event.


Hope that this helps you!


Kind regards,

Rui Barradas

OML.oml
2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Turta,

In addition to Rui's response, a slight different solution would be..

Required Code Changes:

  • ListClear node in the Parent screen Data Source action is not required
  • Introduce a FormRecord variable as the Block input parameter, and associate it with the Form input widgets
  • Block IsSave input parameter is not required
  • Block OnParametersChanges event is not required
  • Define a Block > Input onblur event to pass the current scope Form record value change to the screen
  • In the screen - Block SetDataHandler client action flow, replace the the Screen FormList current row record value with the handler input parameter Form record value.

Note that you will only see the last record as the Feedback message, as it is called in a For Loop. I guess, the reason for using the Feedback message in your case, is to confirm the changes in the Local Screen List variable value w.r.t the block record changes?!

Demo Screen: ParentScreen

Refer to the attached oml


I hope this helps you!


Kind regards,

Benjith Sam

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