Skip to main content

FindFirst

This formula allows you to fetch the first value in an array (list) that satisfies a condition.

JSON Format

{
"type": "findFirst",
"components": ...,
"filter": ...,
"find_first_value_key": ...
}

Fields

FieldTypeRequiredDescription
componentsStatFormulaComponentThe formula for the array (list) you want to get the value from.
filterStatFormulaComponentThe formula for the condition that the resulting value should satisfy to be returned by this FindFirst formula. Anything inside this formula can make use of the $findFirstValue stat, which will contain the current value for the iteration (e.g: if iterating the array ['a', 'b', 'c'], $findFirstValue will first be equal to 'a', then 'b' and then 'c'), thus allowing the formula specified here to access the value of each element in the array one at a time as part of the condition. If you were to specify the optional find_first_value_key parameter, you should use the key given there instead of $findFirstValue to access these values.
find_first_value_keyStringOptional parameter that lets you provide a key to use in the filter formula to access the array's current value in the iteration. e.g: if you are iterating classes, you might want to assign "$class" to the find_first_value_key, to make your system easier to read. This is also helpful when dealing with nested FindFirst formulas, as it will allow inner FindFirst formulas to access the values of outer filter formulas.