I have a page with a single web block in it. The web block has a dropdown with three choices, and depending on the user's choice one of three forms populates the rest of the block. Underneath I have a button, and I need that when the user presses said button a new web block appears under the last one without having anything selected on it.
I think I'd know how to do this in a traditional web app, but my employer demands it to be reactive, and I am quite lost. Any help?
You can do exactly what you just said, creating a structure called Product, in outsystems side, with the attributes you think make sense/you need inside your block, and then you simply have a local variable on screen of type Product List, that you associate to that list widget.
Cheers,
Paulo
Hello Fernando,
I am sorry but it is difficult to understand your query. Can you please elaborate more?
Apologies, English is not my first language.
So in this screen there's the weblock. The block is composed of a dropdown, and three forms. The visibility of these three forms is controlled by the value of the dropdown. There I have no problem. The values that the user inputs on the form will make up a product once the user clicks the save button.
The problem resides in that, under the block, there's a button to add another product, which has to create a clone of that block, completely empty, that will make a different product once saved.
The client is able to make up to a hundred different products per batch, so creating up to a hundred blocks all hidden and controlled by ifs is not an option. I need to know how to make it so that when the Add Product button is pressed, a new block is added to the screen dynamically.
Thank you
Hi,
Basically you want to add a new block, everytime you click on an AddProduct?
in that case you can simply put a list widget with that block inside, and on the addProduct, you do a listAppend to the List.
Each list item is basically your product block, so everytime you listAppend a new item to the list, a new block will appear.
Let me know if this helped.
Don't try to add new block. You can make input fields empty when clicked on add button. And you can use list append to add it in the list. Let me know if you need oml for better understanding
I thought to do that, but the list asks me for a source. In similar questions to mine I've seen suggested that said source should be a Record List of the type the form will create, in my case a Product, but the way the database is built I don't have access to the tables I need to create said structure with every attribute having the correct type.
Is there a solution for the list's source, or am I missing something?
That was how I wanted to do it too, but the designer wants the user to be able to see what products they've added before and change them if they want before saving, so I need to have all of them present at the same time.
If he did that, he wouldn't really be adding a new product, at least in user experience terms, it would be more like clearing what he just typed, even if in the background the record would be added to the list :)
The user would click on a button called "Add another Product", and all he would see is the same form he just filled in being cleared, thus resulting in a weird user experience.
Also, having a list of blocks, the user can easily just go to a past product and be able to apply changes. The way you are suggesting limits the usability as once the user clicks 'Add Another Product' he will have no chance to change anything he has written before.
You can always use structure for temporary holding values or you can create a dummy entity where you can store values just for display and editing purposes and you can save it later it in your main entity
Alright, this worked. Now I just need for the structure to have the correct types, but the block spawning thing works. Thank you!