Skip to content

Basic, Log, and Network elements

Every element on this page is a scriptable task with a script already written for you. Drop one on the canvas, bind its inputs and outputs on the General tab, and you’re done. The code under each entry is exactly what Orchestrator 9.1 generates.

You’ll rarely use them on their own. The lab workflow Wait for a web page, in VCF Orchestrator Guide/Reference, uses five of them together in a small, realistic retry loop: it fetches a page with HTTP get; if that fails, Decrease counter uses up one attempt, a decision asks whether any are left, Sleep pauses, and it tries again. When the page arrives, System log writes a one-line summary. When the attempts run out, it ends with Throw exception.

Workflow editor, Schema tab of Wait for a web page. The palette shows the Basic group (Sleep, Change credential, Wait until date, Wait for custom event, Send custom event, Increase counter, Decrease counter) and the Log group (nine log elements). The canvas shows Fetch the page, Summarise, Log the summary and End along the top, and a retry path below: a red dashed exception arrow from Fetch the page to One attempt used, then Try again?, with a green arrow up to Pause and back to Fetch the page, and a red dashed arrow to a Throw exception element.
Figure R.14. The Basic, Log, and Network groups, and the Wait for a web page workflow built from them.

Run it with https://www.broadcom.com/robots.txt and it completes in under a second with Got 1342 characters from …. Give it an address that answers with an error, and the run makes three attempts, ten seconds apart, before it fails.

Sleep

Pauses the run for a number of seconds. Input: sleepTime (number, in seconds). In Wait for a web page it’s the Pause element.

System.sleep(sleepTime * 1000);

The run keeps its thread while it sleeps. For waits longer than a few minutes, use a Waiting timer instead, which frees the thread.

Pause selected on the canvas of Wait for a web page. General tab, Inputs/Outputs: input sleepTime of type number bound to waitSeconds; there are no outputs.
Figure R.15. Pause, a Sleep element, with its sleepTime input bound to the waitSeconds variable.

Change credential

Runs the rest of the workflow as another user. Input: newCredential (Credential). It calls workflow.changeCredential(newCredential), and does nothing if the credential is the one already in use. Use it rarely, and never with a password typed into the workflow.

Wait until date

Pauses the run until a date. Input: waitDate (Date). It calls System.waitUntil(waitDate, 1000), which checks every second and keeps the thread. The Waiting timer element does the same job without holding a thread, so prefer it for anything longer than a few minutes.

Wait for custom event

Pauses the run until another workflow sends a custom event with the same name, or until a deadline. Inputs: eventName (string), endDate (Date), isExternalEvent (boolean, true for events sent through the REST API). Output: success (boolean), true if the event arrived in time.

var eventType = isExternalEvent ? 'external' : 'internal';
var eventCustom = System.waitCustomEventUntil(eventType, eventName, endDate);
success = (eventCustom != null);

Used in 3.7 Waiting tasks and custom events.

Send custom event

Wakes up every run that waits for an event with this name. Input: eventName (string). It calls System.sendCustomEvent(eventName).

Increase counter

Adds one to a number variable: counter = counter + 1. Bind counter to the same variable as input and output. Use it to count the attempts in a loop, with a decision that stops at a limit.

Decrease counter

Subtracts one: counter = counter - 1. Bind counter to the same variable as input and output. In Wait for a web page, One attempt used counts down attemptsLeft.

Nine elements, one for each combination of where the message goes and how serious it is.

Log (info) Warning Error
System: the run’s log, on the Logs tab System log System warning System error
Server: the server’s event log, kept after the run is deleted Server log Server warning Server error
System and Server: both System and Server log System and Server warning System and Server error

The System elements take one input, text, and call System.log(text), System.warn(text), or System.error(text). The Server elements take text and an extra object (Any) for detail, and call Server.log(text, object) and its siblings. The combined elements do both.

Log the summary selected on the canvas of Wait for a web page. General tab, Inputs/Outputs: input text of type string bound to summary; there are no outputs.
Figure R.16. Log the summary, a System log element, with its text input bound to summary.

Most of the time System log is what you want. Use the Server variants only for events someone must find later, because the server log grows the database. More in 4.6 Logging from scripts.

HTTP get

Reads a URL. Input: url (string). Output: result (string).

var urlObject = new URL(url);
result = urlObject.getContent();

HTTP post

Sends text to a URL. Inputs: url and content (string). Output: result (string), the reply.

var urlObject = new URL(url);
result = urlObject.postContent(content);
Fetch the page selected. Scripting tab: Runtime Environment JavaScript, greyed out; three lines of generated code creating a URL object and calling getContent; a tooltip reads Cannot edit in read-only editor.
Figure R.17. Fetch the page, an HTTP get element. Its code is read-only: typing in it shows Cannot edit in read-only editor.

The script is read-only, as the figure shows. To change it, use a plain scriptable task and copy the line you need.

These two are handy for a quick test. For a real API with authentication, headers, and certificates, use a REST host instead: see 5.2 REST hosts and operations.