unshift

The unshift task adds an element to the beginning of an array.

Potential use case

Suppose you have an older device listed for updating in a dataset and you want to insert a new device that should receive the update first. Use the unshift task to place the new device at the beginning of the dataset.

Properties

IncomingTypeDescription
arrArrayRequired. The array to add an element to at the beginning.
elementNAnyRequired. The element to add to the beginning of the array.
OutgoingTypeDescription
unshiftedArrayArrayThe array with the new element at the beginning.

Example

In this example, the reference value for arr is ["oldDevice"] and elementN is statically set as ["newDevice"].

unshift task with arr set to oldDevice and elementN set to newDevice

The incoming variables are displayed under the Incoming tab in Task History (accessed from Jobs in Operations Manager).

Incoming tab showing the arr and elementN values before the task runs

The unshiftedArray variable returns with ["newDevice"] shifted to the beginning before ["oldDevice"], changing the order of the array.

Outgoing tab showing newDevice at the beginning of the array before oldDevice