"nested recursive Structure data type definition"

I need a record list of structure that contains, amongst others, a record list of the same structures. But when I define it the most intuitive way (adding an attributre of data type record list, with the struct as record definiton), I get the error of this post's subject. Is there a way to define something like that?
Hi Kilian,

The OutSystems language does not allow the creation of structures that, at any depth, include attributes of that very same structure (be they Record or RecorList attributes). The only way to make this sort of inclusions is to duplicate the structure and on the "inner" version of the structure remove the offending attribute (i.e. the one that would cycle back to the "outer" structure).

Although you will effectively be working with two different structures, the Auto Assign funcionality between structures with the same attribute names makes it easy to "convert" between the two.

Hope this helps,

Hi Miguel,

The problem is that I need a tree with an undefined depth, otherwise I could indeed use different structs. But if it's not possible with the Platform, I'll have to resort to different measures (e.g. add a "Depth" atrribute and store everything in the same record list).


Even I am looking for the same hierarchiecal data storage in structures with infinite depth. Any workaround to make this possible?
Hi Thirupathi,

Unfortunately this isn't possible. The technical story is that the platform always initializes all of the attributes of a structure, and if it were the same structure, it would endlessly try to initialize. So no luck there!
Thanks Killian, how did you solve in your application? just wanted to check whether it fits to my application as well. 
Hi Thirupathi,

I solved it by including a Depth or Level attribute which is an integer and specifies the depth/level within the tree. It's not ideal, but it gets the job done. So if you would have something like this:

+--- child1
      +---- child1_1
      +---- child1_2
+--- child2

You'd represent it as:
root 0
child1 1
child1_1 2
child1_2 2
child2 1
Ok Thanks Killian, In my case, i am getting response from third party web service and XMLRecords have to deserialize to structures. I dont have control over that.

Hi Thiru,

Yeah, then you're basically screwed :). Having recursive structures in XML sucks. I guess you can use the XML extension i/o the XMLRecords extension to walk through the response, but it ain't nice...