field_contains()

Test whether a multi-value field (multi-select, multi-user, multi-lookup) contains a given value. Works across field shapes so you don't have to know how the value is stored.

Syntax

field_contains(haystack, needle)

Parameters

Name Type Required Description
haystack array | string yes The field value to search — a list, a single {id,title} object, or a scalar.
needle string | array yes The value to look for. May be an {id,title} object (matched by id).

Returns

true if found, otherwise false. Comparisons are by string value, so "12" and 12 match.

Example

if ( field_contains($record["tags"], "urgent") ) {
    task_assign("tickets", $record["_meta"]["id"], $record["owner"], [
        "title" => "Urgent ticket needs triage"
    ]);
}

Example output

true

Notes

  • Handles multi-select / multi-user lists, multi-lookup lists of {id,title} (matched by id), and single lookups.
  • This is the function behind the visual builder's contains / does not contain conditions.

See also: flow_text()