- 23 May 2023
-
DarkLight
-
PDF
fill (array)
- Updated on 23 May 2023
-
DarkLight
-
PDF
fill Task Purpose
The fill task fills the elements of an array with a static value. You can specify where to start filling the array and where to end. If not specified, all elements will be filled. This task method overwrites (modifies) the original array.
Potential Use Case
Use this task if you have a dataset and you want to create a new dataset populated with some unique values. Likewise, let's say you have a counter and over the course of time the values in the counter need to be increased incrementally. You could use the fill
task to populate the counter with the new values.
Properties
Incoming | Type | Description |
---|---|---|
arr |
Array | Required. The array to be filled. |
value |
Any | Required. The value used to fill each element of the array. |
start |
Number | Optional. The index where to start filling the array. If this property is not provided, it will default to zero. |
end |
Number | Optional. The index where to stop filling the array. If this property is not provided, the array length becomes the default. |
Outgoing | Type | Description |
---|---|---|
filledArray |
Array | The modified array with the elements filled as specified by the value , start and end properties. |
Examples
Example 1
In this IAP example:
-
The incoming
arr
variable is set to["1","2","3","4"]
. -
The
value
variable is contained in theNew Variable:Test
reference task, which is located in another workflow. The value provided by this reference task is[a,b,c]
. -
Parameters for
start
andend
were not provided, so the default will be used. -
With this example, the
filledArray
output should read as[a,b,c],[a,b,c],[a,b,c],[a,b,c]
, which corresponds to the value contained in theNew Variable:Test
reference task. This value was used to fill each element of the incoming array.
Example 2
In this IAP example:
-
The incoming
arr
variable is set to["1","2","3","4"]
. -
The
value
variable isstatic
and the provided reference variable given is42
. -
Parameters for
start
andend
were not provided, so the default will be used. -
With this example, the
filledArray
output should read as[42,42,42,42]
, which corresponds to the reference variable that was provided. Essentially, it filled the entire array with the number42
by replacing all the initial values that were present in thearr
variable.
Example 3
In this IAP example:
-
The
arr
value has been statically set to["Toyota","Mazda","Datsun"]
. -
The
value
used to fill the array is statically set to["Nissan"]
. -
The values for
start
andend
have been statically set to2
, which fills the array from position 2 of thearr
value. -
With this example, the
filledArray
output should be["Toyota","Mazda","Nissan"]
. Essentially, from position 2 of the array,Datsun
was replaced byNissan
.