Hi All,

I know that we cannot add list record within a form widget. To over come this we can make use of web block but this only works when I have saved the form once (id is needed for the primary entity to refer to child entity) .I am in a situation where we I need to save the list data along with form data on single button click on form side .If user don't save the data then non should be added to DB.

Can anyone suggest any approach to do so.

Thanks 

Pranav 

Solution

Hi Pranav,

Essentially, every time you make a change to the table in the webblock, you'd send the List to the main screen and save it in a local variable. Then, when you saved the form, you'd save the main Entity, and then go over your local variable and save the Records that you have stored there.

How easy this is going to be depends on if you have at least Outsystems 11 - it standardized this form of communication between screen elements with Events in the Desktop side of applications (this was previously a Mobile only feature).

If you're not using Outsystems 11, you're left with two choices: Notify actions or this Forge component that implements Event-like functionality.

Solution

Hi Pranav,

Another option is not to use a form widget.

  1. Place your entity controls on the page based on your aggregate, and a list on the page.  The list should use a local variable holding a list of child entities as its record source.
  2. Add an "Add Child" button with Ajax Submit. On click, add a child record to the local variable list, then refresh the list widget.
  3. Add an Ajax submit button for the form.  On click, read child data to store from the list widget's list.

You might find you can use a list of the child entity, but you might find it useful to create a structure for capturing records, which you can map to your child entity.

You also might find the data grid a useful control for editing a list of entities https://success.outsystems.com/Documentation/Development_FAQs/How_to_use_Data_Grid

Hope this helps!

The Add Child action:


The Save action:



Afonso Carvalho wrote:

Hi Pranav,

Essentially, every time you make a change to the table in the webblock, you'd send the List to the main screen and save it in a local variable. Then, when you saved the form, you'd save the main Entity, and then go over your local variable and save the Records that you have stored there.

How easy this is going to be depends on if you have at least Outsystems 11 - it standardized this form of communication between screen elements with Events in the Desktop side of applications (this was previously a Mobile only feature).

If you're not using Outsystems 11, you're left with two choices: Notify actions or this Forge component that implements Event-like functionality.


Hi Afonso Carvalho,

Thanks for the advice . Using local variable of type list seems to be a good idea. So we can pass the list to and from web block as JSON using notify. 

Thank you Afonso Carvalho and Stuart Harris for your suggestion . Really appreciated .