A better way to clear arrays in functions

One of the biggest issues I’ve had when using functions is manipulating arrays specifically clearing an array and then adding items to it again.

The work around is to create a second empty array and then set the array to that value. While this works it is not a very elegant or intuitive solution especially because you are limited on the number of variables your can have in a function.

This appears only to be an issue with functions not in the app editor. In the app editor it works as one would expect. After you clear a list you can then add items to it.

There should be a feature within functions to help clear lists in an easier and more intuitive fashion.

There are other users who have had the same issue you can see in this post https://community.tulip.co/t/function-internal-error-failed-to-push-to-text-list/16249

Interestingly, there are two ways to clear arrays using trigger actions, each with a slightly different result:

  1. Data Manipulation action
    image
    This results in a completely null variable–if you TOTEXT(Array 1) you will get “null” as the result (without the quotes).
  2. Array action
    image
    This results in the array equivalent of an emptystring–if you TOTEXT(Array 1) you will get “[]” as the result (without the quotes).

Which of these would be preferable for clearing an array in functions?

Currently with functions clearing the array results in the first case (in functions it seems to assign a value of “blank” to all null values in the test results). When you use the first case in the data manipulation action you can still add items to the array after the clear. This doesn’t work in functions.
The second option would be the preferred option.
There are sometimes some use cases where you want a variable assigned to null but you can get usually get the same functionality by using the “nullif” expression.

For example this works in the app editor but not in functions