What is Apex Trigger and Validation Rules?

What is Apex Trigger and a Validation Rules?

Apex Trigger.

Apex Triggers in Salesforce enables user to perform custom actions before or after changes to records. Similar to other database triggers, Apex Triggers can be programmatically configured to execute the following operations.

  • Insert.
  • Update.
  • Delete.
  • Merge.
  • Upsert.
  • Undelete.

In Salesforce, triggers are of two types they are

  1. Before Triggers :- Before Triggers are used to validate records before updated to database
  2. After Triggers :- After Triggers are used to access field values like Id or LastModiefiedDate.

Validation Rules.

Validation rules in salesforce contains a formula or expressions that evaluates the data in one or more fields in a record to meet the standards and returns a vale “True” or “False” and it displays error message to the user when the Condition is “False”.

  • Validation Rules help enforce data integrity from both the salesforce.com UI and API.
  • Validation rules fire each time a record is saved and performs the validation against a certain field based upon a formula expression.
  • Validation rules in Salesforce are verified if the data is true , the records is saved. If the data is invalid it dispalys error message.

Formulas

Formulas are dynamically generated fields which are used to calculate or to combine multiple fields. Using Formula fields we can perform some calculation based on other fields and operations based upon those fields.

Example:- For an opportunity you could create a formula that contains a discounted amounted field: {!Amount} – ({!Amount} * {!Pct_Discount}). This amount would display on any page layout, could be used for reporting and would look like a regular field to queries.

Field History

Tracking  Field History is a method of finding  and displaying the field history in the related history for custom objects and Standard object. We can track Salesforce field history for both objects.

  • We can configure each object to track changes to field values (up to 20 fields).
  • Field history can be displayed on the page layout showing the before and after value, who changed the field and the date and time it was changed.
  •  We can contact salesforce.com Support to increase the number of fields that can be tracked for our Organisation.

Click here for :- How to Track Salesforce field history.

Comments on this entry are closed.