I run a workflow to retrieve a VMFolder resource to place new vm.
I used code from this post : to put together a script that takes path string attribute to then traverse all of the VMFolders in order to get the last element in the path attribute (VMFolder).
I am running into little anomaly where in some cases the path is the same, only diff is that they exist in different Datacenters.
This is section of the code that retrieves all of the vm folders. I assumed since I was passing the cluster resource it would only retrieve folders that were in that Datacenter. Probably not right assumption.
How can I modify the folders variable to only run the getallVMFolders on specific Datacenter
var sdkConnection_new = cluster.sdkConnection;
System.log("Path has "+foldercount+" elements, last element "+VMFolderName);
var folders = sdkConnection_new.getAllVmFolders();
// result is an array of type VcFolder
//