Apex Triggers

Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. You can know more about Apex triggers here. You need to create three different triggers

  1. Contact Trigger - If there is any change to the Contact then contact trigger will be invoked

  2. Lead Trigger - If there is any change to the Lead then lead trigger will be invoked

  3. Account Trigger - If there is any change to the Account then account trigger will be invoked

To create a trigger follow the below steps

  • Click on settings icon

  • Then click on Setup option from the dropdown

  • Search for Apex Triggers option and click on it

  • Click on Developer Console button

  • In the developer Console click on File

  • Click on New and Select the Apex Trigger option

  • For the Contact Trigger give the

    • Name as ContactTrigger

    • For sObject select Contact from the dropdown

  • Then paste the below code

trigger ContactTrigger on Contact (after insert,after update,after delete) {
    CustomFitWebHook.callout(CustomFitWebHook.jsonContent(Trigger.new, Trigger.old));
}
  • Atlast save the code

  • For the Lead Trigger give the

    • Name as LeadTrigger

    • For sObject select Lead from the dropdown

  • Then paste the below code

trigger LeadTrigger on Lead (after insert,after update,after delete) {
    CustomFitWebHook.callout(CustomFitWebHook.jsonContent(Trigger.new, Trigger.old));
}
  • Atlast save the code

  • For the Account Trigger give the

    • Name as AccountTrigger

    • For sObject select Account from the dropdown

  • Then paste the below code

trigger AccountTrigger on Account (after insert,after update,after delete) {
    CustomFitWebHook.callout(CustomFitWebHook.jsonContent(Trigger.new, Trigger.old));
}
  • Atlast save the code

Last updated