Posts

Showing posts from June, 2021

LinkedIn

Salesforce - GitHub integration using Webhook

Image
Salesforce supports webhooks for communicating with many other applications. In this post let us see how we can use webhooks to communicate between Github and Salesforce to track details of push event. 1. What is Webhook In Salesforce, we can define what action should happen when a specific event occurs. Triggers and flows can define before and after actions. Similarly, other applications provides event actions called webhooks, which is basically an HTTP POST to external URLs, which are registered under specific event actions. There are multiple applications that currently support webhooks. Github, JIRA, ServiceNow, Twilio, Whatsapp are some examples.  These applications can register multiple subscribers for the same event, thus passing the same message to multiple systems when some event is happening. 2. How to create a Webhook supported URL in Salesforce In Salesforce creating a webhook supported URL involves the below steps: 1. Create Apex REST API First, create a new Apex REST API

Batch Apex - Better Exception Logging using Standard Platform Event - BatchApexErrorEvent

Image
BatchApexErrorEvent is a standard platform event introduced by Salesforce as part of API version 44.0. This mainly helps us to get the details of unhandled exceptions that happened from Batch Apex. To fire exception details to BatchApexErrorEvent, Batch Apex should implement  Database.RaisePlatformEvents interface. Let us cover below in detail: 1. BatchApexErrorEvent Details BatchApexErrorEvent holds below details: Let us implement a batch apex and see how BatchApexErrorEvent is helpful for tracking unhandled exceptions. 2. Sample Batch Apex Scenario Both Account and Contact has a field called Active__c which contains 2 values - Yes, No. When a parent Account is getting deactivated,ie Active=No, we need to mark all child contact's Active also as No. Batch Apex Logic Below Class is implemented to solve this. You can see that this class has implemented  Database.RaisePlatformEvents interface. public with sharing class Batch_ContactDeactivation implements Database.Batchable<sObje