Powered By GitBook
WITH_UNIQUE_ITEM_BY_KEY
Add item to the list, unique by given key

Description

Returns the list with the given item added, but only if the list doesn't already have an object whose Key value matches the given item's Key value.

Function signature

1
WITH_UNIQUE_ITEM_BY_KEY(list: Array, item: Object, key: String) => Array
Copied!
Parameter
Description
List
List to add item to
Item
Item to add
Key
Key whose values to compare to ensure uniqueness

Examples

Formula
Return value
WITH_UNIQUE_ITEM_BY_KEY([{ a: 3, b: 10 }, { a: 2, b: 11 }], { a: 10 } , "a")
[{"a":3,"b":10},{"a":2,"b":11},{"a":10}]
WITH_UNIQUE_ITEM_BY_KEY([{ a: 3, b: 10 }, { a: 2, b: 11 }], { a: 2 } , "a")
[{"a":3,"b":10},{"a":2,"b":11}]
Last modified 11mo ago
Export as PDF
Copy link