Empty a Record List

Empty a Record List


How can I empty a Record List?



Try to create a new local variable on the webflow with type record list and assign it to your var and see if it works.
Hi, basically you have 2 options.
1) is to use ListRemove and iterate over all elements and remove them.
2) is to assign a empty recordlist to the list you want to empty.
The second option is the simpler but you can run into problems if not done properly.
You cannot simply create a empty list and assign it to the one you want to empty. that will only work the first time, since recordlists are passed by reference, once you start adding elements, the empty list will become full also. Use a list duplicate on the empty list instead. You can also create a function that returns a empty list and use it.

Hope this helps
Hello there,

The simplest solution is to use Built In action ListRemove.

Now, since you cannot use it inside a For Each, you will need an if statement which checks if your list is empty.

Example :

If (MyRecordList.Empty) -> Continue; else ListRemove (Index 0).

Best Regards,

Diogo C S Cordeiro

We have developed an action in an extension that does just that, only for ease of use and keeping the code clean.
To call it you just need to pass it the input argument ToObject(YourRecordList).

The code for that particular action is attached.
another option is to create a RecordList of the type you want and then use a Built-in ListDuplicate and then assign your RL with the result of action ListDuplicate.
if you simple assign a new RL to yours, dont know how, but both vars will get the same values.

best regards.
Bruno Rebelo