Hi all,
I don't know why when i use this line :
var task = datastore.browser.searchDatastore_Task(pathFolder, querySpec);
I have a problem with the iteration in the line
for ( var i in searchResults) { }
If i use :
var task = datastore.browser.searchDatastoreSubFolders_Task(pathFolder, querySpec);
All works verry good, but that return me the SubFolders and file with the two boucle for.
I want just to return a repository inside [datastore]/ISO
Thanks,
=================================Error Code ======================================
Error in (Workflow:SNG.TestMountISO / Mount ISO (item1)#12) TypeError: Invalid iterator value
[2018-12-24 23:05:44.007] [E] Workflow execution stack:
***
item: 'SNG.TestMountISO/item1', state: 'failed', business state: 'null', exception: 'TypeError: Invalid iterator value (Workflow:SNG.TestMountISO / Mount ISO (item1)#12)'
workflow: 'SNG.TestMountISO' (65c76171-a0b5-4509-bacb-2e716d486c1c)
| 'attribute': name=datastore type=VC:Datastore value=dunes://service.dunes.ch/CustomSDKObject?id='vSpherelab.itplab.extra%2Cid:datastore-4095'&dunesName='VC:Datastore'
| 'input': name=Repertoire type=string value=
| 'input': name=result type=string value=
| 'input': name=vm type=VC:VirtualMachine value=null
| 'no outputs'
*** End of execution stack.
====================================================End of error code ===============================
var repertory = new Array();
var querySpec = new VcHostDatastoreBrowserSearchSpec();
querySpec.query = null;
var pathFolder = "[" + datastore.name + "]" + "/ISO";
System.log("Datastore Patch : " + pathFolder);
var task = datastore.browser.searchDatastore_Task(pathFolder, querySpec);
//var task = datastore.browser.searchDatastoreSubFolders_Task(pathFolder, querySpec);
var searchResults = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,false,5);
if (searchResults != null) {
for ( var i in searchResults) {
if (searchResults[i].folderPath != null) {
repertory.push(searchResults[i].folderPath );
}
}
}
System.log(repertory);
Hi,
You are getting this error because the variable searchResults that you are trying to iterate over is not an array but an instance of VcHostDatastoreBrowserSearchResults class.
So to collect the names of the matching files from the returned searchResults, you need to change your code to something like:
if (searchResults != null && searchResults.file != null) {
for (var i in searchResults.file) {
if (searchResults.file[i].path != null) {
repertory.push(searchResults.file[i].path);
}
}
}
Hi,
You are getting this error because the variable searchResults that you are trying to iterate over is not an array but an instance of VcHostDatastoreBrowserSearchResults class.
So to collect the names of the matching files from the returned searchResults, you need to change your code to something like:
if (searchResults != null && searchResults.file != null) {
for (var i in searchResults.file) {
if (searchResults.file[i].path != null) {
repertory.push(searchResults.file[i].path);
}
}
}
Thanks Ilian
That's work
I have question
The first return an Array of
searchDatastoreSubFolders_Task(?String_arg0 , ?VcHostDatastoreBrowserSearchSpec_arg1)
The second you tell me it a instance of the VcHostDatastoreBrowserSearchResults
searchDatastore_Task(?String_arg0 , ?VcHostDatastoreBrowserSearchSpec_arg1)
In the Orchestrator there is no indication that searchDatastore_Task is instance of VcHostDatastoreBrowserSearchResults
How can i make difference between this to Method ???