Process a text file from a Resource Element through an Array
This example workflow shows how you can use a ResourceElement containing a list of virtual machine names and execute a workflow for each of the VMs in the list. The workflows and actions are available as a package here: com.vmwarebits.vmlistExample.zip.
To use the workflow yoi create a ResourceElement and import a text file that contains the virtual machine names, such as in the next image.
//get the content from the ResourceElement as a Mime attachment type contentMime = vmlist.getContentAsMimeAttachment(); //get the contents from the Mime attachment contentText = contentMime.content //split the contents (text file) in lines and store in an array vmarray = contentText.split(/\r\n|\r|\n/); vmarray.sort();
The example workflow executes this workflow to toggle the power state of a VM. But this can of course be changed to any other workflow you like.