> For the complete documentation index, see [llms.txt](https://doc.customfit.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.customfit.ai/integrations/salesforce/apex-triggers.md).

# 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](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm). 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

![](/files/-MX_RnlFgv1GEnxN4TpC)

* Then click on Setup option from the dropdown

![](/files/-MX_Rrt76Hq96EiiQE7o)

* Search for Apex Triggers option and click on it

![](/files/-MXXg0NQ6JHQsqMXoZzG)

* Click on Developer Console button

![](/files/-MX_SRSXOTn9J3PxdJJi)

* In the developer Console click on File
* Click on New and Select the Apex Trigger option

![](/files/-MX_TIyNyVNH8VxFvB1L)

* For the Contact Trigger give the&#x20;

  * Name as ContactTrigger
  * For sObject select Contact from the dropdown

![](/files/-MX_a-v-z_ZJnB7_40LH)

* 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&#x20;

  * Name as LeadTrigger
  * For sObject select Lead from the dropdown

![](/files/-MX_cOITJVJWMrZ8XWRt)

* 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&#x20;

  * Name as AccountTrigger
  * For sObject select Account from the dropdown

![](/files/-MX_crFga9zhUrTNbS0J)

* 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
