I'm trying to create a new snapshot by using only the VMs actual name not "vm-21" etc. To do this I have created the following workflow:
The output parameter of Get VM by Name is:
And the input parameter of Create a Snapshot is:
However if I run this I get the error:
Error in (Dynamic Script Module name : createSnapshot#1) ReferenceError: VM cannot be null
Is the output parameter of the first workflow incompatible with the second? and if so, how can I pass it correctly.
Thanks.
Hi,
The output of the first workflow and input for the second are of one and the same type VC:VirtualMachine, so they are compatible.
This error means that the second workflow has received a null virtual machine as input; that is, the virtual machine with such name and UUID is not found by the first workflow. Most likely, you haven't provided the correct UUID.
Could you check the workflow execution Logs tab in the client; there should be a line starting with out vm =. Most likely, in your case it will be out vm = null
What is the format of the UUID you provided? It should look something like 42191452-3898-86b2-8942-b191dc784b02, not vm-1234. It is also displayed on the Logs tab (assuming there is at least one VM with a name matching the input value); search for a line starting with uuid =
Hi,
The output of the first workflow and input for the second are of one and the same type VC:VirtualMachine, so they are compatible.
This error means that the second workflow has received a null virtual machine as input; that is, the virtual machine with such name and UUID is not found by the first workflow. Most likely, you haven't provided the correct UUID.
Could you check the workflow execution Logs tab in the client; there should be a line starting with out vm =. Most likely, in your case it will be out vm = null
What is the format of the UUID you provided? It should look something like 42191452-3898-86b2-8942-b191dc784b02, not vm-1234. It is also displayed on the Logs tab (assuming there is at least one VM with a name matching the input value); search for a line starting with uuid =
Ah that's my mistake. I was only providing the input name. When I run the workflow and only provide the name and skip the UUID it still returns VM information so I was assuming it had worked, but obviously it does not create the full output VC:VirtualMachine.
Unfortunately there doesn't seem to be a workflow for just "Get VM by Name"
The name alone is not enough to uniquely identify a virtual machine - you can have multiple VMs named eg. MyVM in different folders.
There is a workflow 'Get virtual machines by name' which returns an array of virtual machines. If you are sure that your virtual machines have unique names, you can use it and get the first element from the result array.
Will that output always pass the first variable in the array, or would I need to use a script to get the first output and pass it to the next workflow?
You cannot directly bind a single element of a given type and array of elements of the same type, even if the array contains only one element. In some cases, it would be nice if such binding is allowed, but in other cases it could lead to many hard-to-troubleshoot errors at runtime.
So you need to write scripting code to fetch the first element from the array, store it into an attribute, and bind this attribute to the single element.