Make it possible to Clone a Structure Instance

By Robert Metcalf on 14 Jul

When using services Structures are created for me.

I create Actions which other module developers can call to obtain the data for the service. I want to isolate the details of how I obtained the data so when the service changes my action can have the same instance and all the UI using the data doesn't need to be re-developed.

To achieve this I copy the structure and create my own structure of a similar name. I create a public action which uses the copied structure as output. It has to copy the data from the generated structure to the cloned structure.

Sometimes this is complex and error prone and requires many sometimes nested loops.

Can there be a single action which could do this if the structures matched?

(I understand that when the service interface changes in future I would have to fall back to manual assignment as the new structure would no longer match.)

What version are you using? Recent versions (9.X and later) are much better in some scenarios about matching different types with similar attributes up.


J.Ja

I am using Outsystems Studio 9.1.501.0

I have a service with a complicated response structure. The wizard produced a structure called PayslipResponse. This has some attributes which are basic types and others with have other structures as their type. There is more than one level of nesting.

I copy all these structures and name the copy PayslipResponseEXT. 

In my action I want to assign the service return variable (of type PayslipResponse) to the action output (of type PayslipResponseEXT) When I use a single assign I get an error:

"Invalid Data Type 'PayslipResponseEXT' data type required instead of 'PayslipResponseType Record'

My solution is to have lots of assign statements assigning each basic data type and where necessary loops where I have lists. The auto assign feature helps with this a little.

Robert -

I suggest writing an Extension for this, that can use reflection or something similar to do the deep clone. Would love to see something like that hit the Forge!

J.Ja