- 23 May 2023
-
DarkLight
-
PDF
unshift
- Updated on 23 May 2023
-
DarkLight
-
PDF
unshift Task Purpose
The unshift task is used to add an element to the beginning of an array.
Potential Use Case
Suppose you have an older device that is listed for updating in a dataset and you want to insert a new device that will get the update first. You could run the unshift task to list the new device at the beginning of the dataset.
Properties
Input and output parameters are shown below.
Incoming | Type | Description |
---|---|---|
arr |
Array | Required. A given array to add an element to at the beginning. |
elementN |
* | Required. The element added to the beginning of an array. |
Outgoing | Type | Description |
---|---|---|
unshiftedArray |
Array | The shifted array with the new element at the beginning. |
Example
In this IAP example:
-
The Reference value for the
arr
variable is["oldDevice"]
, and theelementN
variable is statically set as["newDevice"]
.
-
The incoming variables are displayed under the Incoming tab in Task History, which is accessed from Jobs in Operations Manager.
-
The
unshiftedArray
variable that returns has shifted["newDevice"]
to the beginning before["oldDevice"]
, which changes the order of the array.