I am running vRO 6.0.1. I have built a dynamic type for Veeam. I can see the objects in the inventory and can select them as attributes in workflows. I'm attempting to get the Dynamic Type Object through a script and set it as an output variable of the script but its not working. I have created the dynamic type using the Dynamic Types Plug-In Generator v2.
I have the namespace "Veeam" with the types:
VeeamHost
jobFolder
job
I set an output attribute with the type "DynamicTypes:Veeam.job" and name jobOut
My script is just:
jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");
System.log("Found Job: " + jobOut);
After execution the jobOut variable is blank. In the logs i see:
Found Job: DynamicWrapper (Instance) : [DynamicTypesDynamicObject]-[class com.vmware.o11n.plugin.dynamictypes.model.DynamicObject] -- VALUE : dynobj:[ __ns:Veeam __tp:DynamicTypes:Veeam.job __id:29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae]
Does anyone have an idea of how to populate the DynamicTypes:Veeam.job output with the actual veeam job i got via the script?
Could you check what happens if you replace the line
jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");
with
jobOut = DynamicTypesManager.getObject("Veeam", "job", "29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");
Could you check what happens if you replace the line
jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");
with
jobOut = DynamicTypesManager.getObject("Veeam", "job", "29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");
That did it.
I thought i could use the "Object" or "Any" return types to populate their real types. While this works and im going to use it from now on, should my original code have worked?
If I understand it correctly, the question if whether System.findForType(...) should work if the jobOut type is changed from concrete dynamic type Veeam.job to generic DynamicObject or Any? If so, the answer is no - it shouldn't matter what is the type of the output parameter as long as it is compatible with the type of the actual value. In your case, most probably you won't see the correct value in 'Variables' table when you use Server.findForType() no matter what is the type of jobOut - Veeam.job, DynamicObject or Any, and when you use DynamicTypesManager.getObject(), you should see the correct value in 'Variables' table if you use Veeam.job or DynamicObject types for jobOut.
I made the same mistake using Server.findForType() since this is the universal method I use for any vCO object.
Would it make sense or even be possible to have it working as DynamicTypesManager.getObject() ?
While we do have the solution to make it work I am sure several people will have the same issue.