How to get List from Weblock to Parent for Duplicate (Nested List)
Question
Application Type
Reactive
Service Studio Version
11.10.19 (Build 41208)

Hello,


I have a nested list between Header and Detail.


There's a Duplicate Header button that's used for duplicate both header and detail. When the button is clicked, I want the list to appear as follows:

Is there any tips on how to pass the detail list from web block to the parent?


I attached the .oml file below.


Thank you before.


Regards,

Vivian

TestingNestedList.oml

Solution

Hi Vivian, with the current implementation that you have, it's is impossible to achieve what you wanted, so I changed your module, please have a look. 

First, the screen structure needs to a nested list, otherwise, you won't be able to duplicate the list in an easy way.

Second, whenever there was a change to the DescriptionList, that change has to be notified to the parent, like Mishika and I explained. When you were adding a new description to the list, you had an event notifying the parent, awesome job there, but then, if the description was changed, the parent was not aware of the changed, meaning if you were going to duplicate the list, you would end up with a list of empty description. 

For that, I added an event to the input's onBlur. I didn't do it onChange because of the way React works, the list would be constantly changing. There are better ways to do this, this is just an example of the concept that I think you were not understanding.

Third, change the duplicate logic, now with clean structures, it is much easier now. 


Let me know if you understood everything or you need a deep dive on any of the steps. 


Gabriel Cardoso

TestingNestedListFix.oml

Hi Vivian 

You can use Event to pass your list to the parent. Your input to the event would be of the type  DetailStruct List. You would have to trigger your event (could be on a button click) and send the data as an input. This would be accessible in the event handler in parent. 

Hello, Mishika.


Thank you for your answer.

I tried to use event to pass my DetailList and I got the data when I checked it with debugger. But when the duplicate process is done, the DetailList remains empty.

I attached the .oml file below.

TestingNestedList.oml

Hi Vivian 

You can use List Append All action to get all your elements at once from source list to destination list. Once you have your list in parent you would have to assign it to input parameter of the new block you want to send it to. 

The flow would be like:

1. Create a list in a block (Child 1)

2. Pass the list from Child 1 to Parent block 

3. Pass the list from Parent to Child 2 (create a new one if it doesn't exist)

Solution

Hi Vivian, with the current implementation that you have, it's is impossible to achieve what you wanted, so I changed your module, please have a look. 

First, the screen structure needs to a nested list, otherwise, you won't be able to duplicate the list in an easy way.

Second, whenever there was a change to the DescriptionList, that change has to be notified to the parent, like Mishika and I explained. When you were adding a new description to the list, you had an event notifying the parent, awesome job there, but then, if the description was changed, the parent was not aware of the changed, meaning if you were going to duplicate the list, you would end up with a list of empty description. 

For that, I added an event to the input's onBlur. I didn't do it onChange because of the way React works, the list would be constantly changing. There are better ways to do this, this is just an example of the concept that I think you were not understanding.

Third, change the duplicate logic, now with clean structures, it is much easier now. 


Let me know if you understood everything or you need a deep dive on any of the steps. 


Gabriel Cardoso

TestingNestedListFix.oml

Hello, Gabriel and Mishika.


I tried what you both suggested and it works.


Thank you so much ! :)


Regards,

Vivian

Hi Vivian.


Is it possible to move the Duplicate button inside of the Block?

One possible solution is to have the Duplicate button inside of the Block so it can notify the parent with the Header and Details List. 

The alternative is to have a hidden button inside of the block, doing the same as before, and your Duplicate button would do a JS click to perform a duplicate. Additional logic would be required to identify which List Item do you want to duplicate.


There are some other solutions that involve storing the records on a temp table, but the main concept is the same, the child block has to "notify" the parent with it's content.


Gabriel Cardoso

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