6. Event
The context.event object is injected at execution time and gives you access to what changed and what the record looked like before the change. It is most commonly used inside onUpdate triggers.
context.event.updates
sync· returnsobject
Contains the new values for any fields that were just changed. Only fields that were part of the triggering update are present. You can also write back to this object to set computed field values as part of the same update.
Prop
Type
if (context.event.updates.Price) {
context.event.updates.TotalItemAmount =
Number(context.event.updates.Price) * Number(context.event.innerValue.Quantity);
}
Writing to context.event.updates.FieldName is how you set a computed value on the record as part of the same save operation — the platform will persist the value you assign.
context.event.innerValue
sync· returnsobject
Contains the original values of all fields on the record before any updates were applied. Use this to read fields that were not part of the triggering change.
Prop
Type
if (context.event.updates.Quantity) {
context.event.updates.TotalItemAmount =
Number(context.event.innerValue.Price) * Number(context.event.updates.Quantity);
}
Use context.event.updates for changed fields and context.event.innerValue for unchanged ones. Mixing them up is the most common source of undefined values in onUpdate functions.