flow_eq()

Compare a field to a value when either side might be a multi-value field (multi-select, multi-user, multi-lookup). Those fields hold a list, and a plain == between a list and a single value is never true, so if ( $record["channel"] == "LinkedIn" ) silently never fires. Use flow_eq() instead.

Syntax

flow_eq(a, b)

Parameters

Name Type Required Description
a mixed yes First value. A field value (list, single {id,title} object, or scalar) or a literal.
b mixed yes Second value, in the same shapes. Order does not matter.

Returns

true when the two are equal, otherwise false.

When one side is a list, the comparison is exact: the list must hold that one value and nothing else. A record with both "LinkedIn" and "Twitter" selected is not equal to "LinkedIn". To test whether a value is merely one of several, use field_contains().

Example

if ( flow_eq($record["channel"], "LinkedIn") ) {
    task_assign("schedule", $record["_meta"]["id"], "andreas@example.com", [
        "title" => "LinkedIn post is live, re-share it"
    ]);
}

Example output

true

Notes

  • Comparisons are by string value, so "12" and 12 match.
  • Lookup values match by id, whether the field holds one linked record or several.
  • Scalar values compare exactly as == always did, so single select fields, text and numbers are unaffected.
  • null keeps its normal behaviour: an empty multi-value field is equal to null, which is what the is empty and is not empty conditions rely on.
  • This is the function behind the visual builder's equals and not equals conditions. The builder inserts it for you, so you only need it when writing PHPScript by hand.

See also: field_contains(), flow_text()