4.1

Table Of Contents
}
}
}
}
Set vCenter Server Option Values
The following JavaScript example allows Orchestrator to set vCenter VcOptionManager option values.
var myVcOptionValue = new VcOptionValue();
myVcOptionValue.key = VimAdvancedOptionKey;
myVcOptionValue.value_LongValue = VimAdvancedOptionValue;
You can set the following optional value types as VcOptionValue attributes.
value
Attribute is a string value.
value_FloatValue
Attribute value is a float value.
value_IntValue
Attribute value is an integer value.
value_LongValue
Attribute value is a long value.
Workflow Scripting Examples
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.
Return All Workflows Run by the Current User
The following JavaScript example obtains all workflow runs from the server and checks whether they belong
to the current user. You can use this scripting with Webview components, for example.
var allTokens = Server.findAllForType('WorkflowToken');
var currentUser = Server.getCredential().username;
var res = [];
for(var i = 0; i<res.length; i++){
if(allTokens[i].runningUserName == currentUser){
res.push(allTokens[i]);
}
}
return res;
Schedule a Workflow
The following JavaScript example starts a workflow with a given set of properties, then schedules it to start
one hour later.
var workflowToLaunch = myWorkflow ;
// create parameters
var workflowParameters = new Properties() ;
workflowParameters.put("name","John Doe") ;
// change the task name
workflowParameters.put("__taskName","Workflow for John Doe") ;
// create scheduling date one hour in the future
vCenter Orchestrator Developer's Guide
126 VMware, Inc.