How to assign a 3d list to another 3d list with a slightly different structure
Application Type
Mobile
Service Studio Version
11.10.9 (Build 38535)

Hi here is the context:

I have 2 variables with similar structures. The only difference in structure is shown below, where one has ImageData but the other does not.


I want to be able to assign the values of Service variable to the ProviderService variable so that ImageData is not included but the rest of the attributes are. But due to the difference in structure types, I am unable to do so. I found that OutSystems is able to assign variables of different structures as long as it is not a nested structure like so:

But when it comes to the nested structure Subservices, I cannot do any further mapping as seen by the Subservices highlighted in red due to different structure types.

In my attached OML file, I thought of looping through the nested lists to assign each record one by one but I do not know where and how to start assigning the variables. I find it complex because it is a 3D nested list.

Would really appreciate any help!


Note: In case you ask, there is a reason why I need to have 2 different structures and I created the attached OML as a sample to illustrate the issue I am facing.

Lists.oml

Hi,

to offer an alternative that reduces the complexity for you now and for any future developer that has to work on it :

You can avoid all loops by creating a dedicated mapper function for each lower level in your structures.

So in your case, 

1) make an action with function = true, taking in a list of subservice image of the source structure, putting out a list of subserviceImage of the target structure.  Do just an assign of in list to out list, and as there is only one level, all should be possible with mapping.

2) make an action with function = true, taking in a list of subserviceName of the source structure, putting out a list of subserviceName of the target structure.  Again just an assign, and now in the mapping, use function 1 to map the listOfSubserviceImages.

3) now you can use a single assign to set value of variable of type Service to the value of a variable of type ProviderService, and now in the mapping, use function 2 to map the listOfSubserviceNames in it.


Hope this makes sense, see also attached OML that has a demo of this idea.


Good luck,

Dorine

rwDemoAssignStructures.oml

Hello,

Just place a second assign after what you had already done as follows:

And if you need to map more, just add another more detailed assign

Regards

Hi,

to offer an alternative that reduces the complexity for you now and for any future developer that has to work on it :

You can avoid all loops by creating a dedicated mapper function for each lower level in your structures.

So in your case, 

1) make an action with function = true, taking in a list of subservice image of the source structure, putting out a list of subserviceImage of the target structure.  Do just an assign of in list to out list, and as there is only one level, all should be possible with mapping.

2) make an action with function = true, taking in a list of subserviceName of the source structure, putting out a list of subserviceName of the target structure.  Again just an assign, and now in the mapping, use function 1 to map the listOfSubserviceImages.

3) now you can use a single assign to set value of variable of type Service to the value of a variable of type ProviderService, and now in the mapping, use function 2 to map the listOfSubserviceNames in it.


Hope this makes sense, see also attached OML that has a demo of this idea.


Good luck,

Dorine

rwDemoAssignStructures.oml

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