So CompositeTypes... are pretty compelling. Seems like they either are similar or actually are Js Object Types as you can use the Object() constructor to create instances that will match up with a CompositeType easily enough. They seem better than working with Properties.
I have been doing quite a bit of discovery today, and I managed to get an Array of CTs to be rather workable. I am sure there are some out there who find my minor skills remedial, but I am sure there are others who would be interested in seeing some of my testing results. Where I am seeing a benefit with these types is: whilst in the execution of a workflow, data from different sources and of different types can be put together and referenced logically as a single object. An array of these objects allows foreach activities, search activities, database loads, etc to be object.name-referential. I have no idea if CompositeTypes will always be supported in vRO or if they have a shelf life. It is interesting nonetheless...
I created a single composite type as an Array...
I added a couple of values...
Ran workflow from a single Scriptable Task with the below script with a single input of the arrayComp composite type. .
// One Array of Composite types defined as an Attribute as // Array/CompositeType(name:string,notes:string):test) arrayComp // One DEFAULT Input was added as the first position in the array // through Attribute Value input. name:"one",notes:"two" // Note: Composite Types do not need to have all the same types defined //(e.g. "string, string" could be "string, object, number, VCAC:VirtualMachine" //create an object with a third variable to overload Array position 2. var testing = new Object(); testing.name = "bob"; testing.notes = "slob"; testing.extra = "job-overload"; // overload arrayComp.push(testing); // load testing object into arrayComp System.log("Pushed Object into Composite Array with extra value position..."); System.log("arrayComp length = " +arrayComp.length); // Array is 2 CompositeType Units long now System.log("Listing to show extra value..."); System.log(arrayComp[1].name); System.log(arrayComp[1].notes); System.log(arrayComp[1].extra); // This only exists in the second array object System.log ("Looping through all Composite Types with Sys logs to show extra position is *undefined* in Array position 1..."); for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); System.log(Comp.extra); // only overloaded Composite type maintains extra position } //This tests creating an Object with the same mapping as the Composite Type //...then overwritting the first Compsite Type in the Array with the Objects values System.log("Test Replacement of one Composite Type in an Array with an Object"); var replacement = new Object(); replacement.name = "sam"; replacement.notes = "ham"; System.log("Replacing Array position 1 with new value, object overwrite."); arrayComp[0] = replacement; // Takes Object and overwrites arrayComp[0] slot for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); System.log(Comp.extra); } //Test removing a Composite Type from array and assign to variable to work with individually System.log("Pull off last CompositeType into a single Composite variable..."); var singleComp = arrayComp.pop(); System.log("arrayComp length = " +arrayComp.length); // Array is 1 CompositeType Units long now System.log(singleComp.name); System.log(singleComp.notes); System.log(singleComp.extra); // last Array position was overloaded so this exists //Test assignment of composite type to new array position System.log("Push Composite type in first array position back into array..."); arrayComp.push(arrayComp[0]); System.log("arrayComp length = " +arrayComp.length); // Array is 2 CompositeType Units long now for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); } //Test direct assignment System.log("Direct Assignment..."); arrayComp[1].notes = "Bologna"; for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); } // Strange behavior noted with above. Bologna should have only printed in second array position. // Overload arrayComp[1] System.log("Strange Behavior..."); arrayComp[1].extra = "WTF-over"; for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); System.log(Comp.extra); } //arrayComp[0] and arrayComp[1] are the same thing (pointer to same place?)... careful with that in the future // Test push back in the singeComp Composite Type System.log("Push back in singleComp."); arrayComp.push(singleComp); System.log("arrayComp length = " +arrayComp.length); // Array is 3 CompositeType Units long now for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); System.log(Comp.extra); } // Direct modification of array position 3, *extra* variable arrayComp[2].extra = "no-job. The end."; for each (Comp in arrayComp) { System.log(Comp.name); System.log(Comp.notes); System.log(Comp.extra); } // fin