fill (array)
  • 23 May 2023
  • Dark
    Light
  • PDF

fill (array)

  • Dark
    Light
  • PDF

Article summary

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 the New Variable:Test reference task, which is located in another workflow. The value provided by this reference task is [a,b,c].

  • Parameters for start and end 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 the New Variable:Test reference task. This value was used to fill each element of the incoming array.

    arrayFill-ex01

Example 2

In this IAP example:

  • The incoming arr variable is set to ["1","2","3","4"].

  • The value variable is static and the provided reference variable given is 42.

  • Parameters for start and end 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 number 42 by replacing all the initial values that were present in the arr variable.

    arrayFill-ex02

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 and end have been statically set to 2, which fills the array from position 2 of the arr value.

  • With this example, the filledArray output should be ["Toyota","Mazda","Nissan"]. Essentially, from position 2 of the array, Datsun was replaced by Nissan.

    arrayFill-ex03


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.