4.2.1

Table Of Contents
n
Simple string exception type checking, must use the following pattern in scripted elements in workflows.
if (typeof(errorCode)=="string"
&& errorCode.indexOf("VMwareNoSpaceLeftOnDatastore:")
== 0) {
// Do something useful here
}
Orchestrator JavaScript Examples
You can cut, paste, and adapt the Orchestrator JavaScript examples to help you write JavaScripts for common
orchestration tasks.
For scripting examples specific to the JavaScript APIs that the different plug-ins provide, see Using vCenter
Orchestrator Plug-Ins.
n
Basic Scripting Examples on page 113
Workflow scripted elements, actions, and policies require basic scripting of common tasks. You can cut,
paste, and adapt these examples into your scripted elements.
n
File System Scripting Examples on page 115
Workflow scripted elements, actions, and policies require scripting of common file system tasks. You
can cut, paste, and adapt these examples into your scripted elements.
n
LDAP Scripting Examples on page 116
Workflow scripted elements, actions, and policies require scripting of common LDAP tasks. You can cut,
paste, and adapt these examples into your scripted elements.
n
Logging Scripting Examples on page 116
Workflow scripted elements, actions, and policies require scripting of common logging tasks. You can
cut, paste, and adapt these examples into your scripted elements.
n
Networking Scripting Examples on page 116
Workflow scripted elements, actions, and policies require scripting of common networking tasks. You
can cut, paste, and adapt these examples into your scripted elements.
n
Workflow Scripting Examples on page 117
Workflow scripted elements, actions, and policies require scripting examples of common workflow tasks.
You can cut, paste, and adapt these examples into your scripted elements.
Basic Scripting Examples
Workflow scripted elements, actions, and policies require basic scripting of common tasks. You can cut, paste,
and adapt these examples into your scripted elements.
Access XML Documents
The following JavaScript example allows you to access XML documents from JavaScript by using the
ECMAScript for XML (E4X) implementation in the Orchestrator JavaScript API.
NOTE In addition to implementing E4X in the JavaScript API, Orchestrator also provides a Document Object
Model (DOM) XML implementation in the XML plug-in. For information about the XML plug-in and its sample
workflows, see the Using vCenter Orchestrator Plug-Ins.
var people = <people>
<person id="1">
<name>Moe</name>
</person>
Chapter 2 Scripting
VMware, Inc. 113