Choose where you’d like to start

insertAll

Table of Contents

Overview

The insertAll function adds a list of specified elements or key-value pairs to a collection.

Syntax

To insert key-value pairs:

<collectionVariable>.insertAll(<keyValueList>);

(OR)

To insert elements:

<collectionVariable>.insertAll(<elementList>);

where,

ParameterData typeDescription
<collectionVariable>DECIMAL

The variable to which the list of key-value pairs or elements will be added.

If the variable contains key-value pairs, this function will only accept key-value pairs as arguments. If elements are specified, a runtime error will be encountered.

If the variable contains elements, this function will only accept elements as arguments. If key-value pairs are specified, a runtime error will be encountered.

<keyValueList>LIST

The list of key value pairs which will be inserted.

If a duplicate key is specified, its new value will overwrite its existing value, and the new key-value pair will not get added.

<elementList>LIST

The list of elements which will be inserted.

Examples

 products = collection("Creator", "CRM", "Campaigns");
 products.insertAll({"Analytics", "Connect"}); // inserts "Analytics" and "Connect" to the existing collection
 productVersion = collection("Creator" : 5);
 productVersion.insertAll({"CRM" : 5, "Campaigns" : 2}); // inserts the new key-value pairs to the existing collection

Get Started Now

Execute