I have a web block that takes a parameter as the product Id to render the information in that web block, so now it will render multiple web blocks according to the id. And I have a function to add information and have to reload the web block containing the changed id. Can it be done?
Hello Vo,
Yes, this is possible. Since you have an input parameter passed to the block and you are showing data based on that input parameter you need to use OnParameterChanged Event and handler to show data related to the new ID always.
You can see that in the attached OML. I am saving information also in this OML but in my case, the data is passed to the screen and then it Is saved.
Let me know if this helps and also if you have any further questions.
Regards,
Neha
Thank you, I did it, and I have another related thing which is I have a list of tasks, for example task 1, when clicking on task 1, it will show task 1.1 task 1.2, task 2 will have task 2.1 2.2, I use web block to render the interface of list task 1.1 task 1.2 (it's like a submenu). Next, I have an add button next to it to add for example add task 1.3 to task 1. so when clicking that add button, it will only refresh the data of the task id that I added to. Can you help me thank you.
Hi @Vo Ngoc Truong,
Web blocks auto re-renders whenever an input parameter changes.
You can also check the below thread for detailshttps://www.outsystems.com/forums/discussion/82859/webblock/#RegardsKrishnanand Pathak
Hi @Vo Ngoc Truong ,
I'm not following exactly what you are doing, but if I'm reading you correctly, the generic problem you are trying to solve is :
When I have a list of webblocks, and I know that only the data of one of them needs to be refreshed, how do I do that ?
Is that the question ?
So there is 2 questions here :
part one
The only low code way to tell a webblock to do something from the outside, is through it's OnParametersChanged. So let's say you only pass in the id of a task, and that id is not changing, (only the record data identified by that id) you will have to add an extra artificial input parameter on the webblock to force an OnParametersChanged. I see often that a boolean is used for this called "NeedsRefresh" or something like that, I personally prefer to use a counter.
So
part two
Now you have a list of blocks in the parent, and you only want to refresh the single block that needs it. So you can't get away with a single local variable anymore, you'll need a list of counters.
Dorine