I would really appreciate if someone can guide me to check if a particular field is included in update call inside a before/after update trigger. Many thanks.
Trigger will include all fields of that sobject for which it is invoked. You can check previous(old) value and current(new) value of any field in that object and can compare it and can do the operation accordingly.
Apex Trigger explained with an example Below are the steps to be followed: Create a field in 'Account' with label 'Field Update' and data type as 'Checkbox' Now create a trigger on Contact. Navigate to Setup ->Build ->Customize ->Contacts ->Triggers.
In Oracle Apex, you can check if an item value changed using the JavaScript API method isChanged() .
You can also view all triggers in Setup by entering Apex Triggers in the Quick Find box, then selecting Apex Triggers. You can add, edit, or delete Apex using the Salesforce user interface only in a Developer Edition organization, a Salesforce Enterprise Edition trial organization, or sandbox organization.
All fields are always present in the trigger regardless of whether they are dirty or not, to ascertain if a specific field has been modified you have to retrieve a previous version of the row using oldMap
map which is a Map<ID, sObject>
and compare the values in old and new. For example
trigger CaseOnParticularFieldUpdate on Case (before update) {
for (Case c: Trigger.new) {
Case oldCase = Trigger.oldMap.get(c.ID);
if (c.Field != oldCase.Field) {
// field was updated, do some magic here
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With