flow_changed()
Test whether a field actually changed in the update that triggered the flow. Compares the value on $record (after the save) with the value on $before (as it was), ignoring anything the system works out at read time rather than storing.
That last part is why a plain != is not enough. Some fields carry extra information that is calculated every time the record is read, not saved with the value. A signature field is the clearest case: alongside the signature it reports whether the signed document still matches what was signed, and that check runs fresh on every read. Compare two reads with != and a record whose document was edited looks like a record whose signature changed, even though nobody touched the signature.
Syntax
flow_changed(now, before)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
now |
mixed | yes | The value after the update, normally $record["field"]. |
before |
mixed | yes | The value before the update, normally $before["field"]. |
Returns
true when the stored value changed, otherwise false.
Example
if ( flow_changed($record["signature"], $before["signature"]) ) {
task_assign("contracts", $record["_meta"]["id"], "andreas@example.com", [
"title" => "Contract was signed, file it"
]);
}
Example output
true
Notes
- Only available on On Update flows, which are the only ones that have a
$beforerecord. - This is the function behind the visual builder's changed condition. The builder inserts it for you, so you only need it when writing PHPScript by hand.
- For ordinary fields (text, numbers, dates, selects, lookups) it behaves exactly like
!=. - A signature's verification result still shows on the record and in the record's history. Ignoring it here only means "the document was edited" does not get reported as "the signature changed".
See also: flow_eq(), field_contains()