fill

The fill task fills the elements of an array with a static value. You can specify where to start and stop filling. If not specified, all elements are filled. This task overwrites (modifies) the original array.

Potential use case

Use this task when you have a dataset and want to populate it with some unique values. For example, if you have a counter whose values need to be incremented over time, you could use the fill task to populate the counter with the new values.

Properties

IncomingTypeDescription
arrArrayRequired. The array to be filled.
valueAnyRequired. The value used to fill each element of the array.
startNumberOptional. The index where to start filling the array. Defaults to 0 if not provided.
endNumberOptional. The index where to stop filling the array. Defaults to the array length if not provided.
OutgoingTypeDescription
filledArrayArrayThe modified array with elements filled as specified by the value, start, and end properties.

Examples

Example 1

In this example:

  • The incoming arr variable is set to ["1","2","3","4"].
  • The value variable is contained in the New Variable:Test reference task, located in another workflow. The value provided is [a,b,c].
  • start and end were not provided, so defaults are used.
  • The filledArray output is [a,b,c],[a,b,c],[a,b,c],[a,b,c] — each element of the incoming array is replaced with the value from the reference task.
fill example 1 — fill all elements with a reference task value

Example 2

In this example:

  • The incoming arr variable is set to ["1","2","3","4"].
  • The value variable is static with a value of 42.
  • start and end were not provided, so defaults are used.
  • The filledArray output is [42,42,42,42] — the entire array is filled with 42, replacing all initial values.
fill example 2 — fill all elements with a static value

Example 3

In this example:

  • The arr variable is statically set to ["Toyota","Mazda","Datsun"].
  • The value used to fill the array is statically set to ["Nissan"].
  • Both start and end are statically set to 2, so filling begins at position 2 of the array.
  • The filledArray output is ["Toyota","Mazda","Nissan"]Datsun at position 2 is replaced by Nissan.
fill example 3 — fill from a specific index