slideshow 6 slideshow 4 slideshow 8 slideshow 1 slideshow 2 slideshow 3 slideshow 5 slideshow 7

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:

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.

Resource Element

Next you create a workflow that uses the ResourceElement and a Javascript Element that parses through the list and stores the VM names in an array.

Resource Element Array

Resource Element Array

Here is the contents of the Javascript Element:

//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/); 

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.

Resource Element Array


Follow us on LinkedIn