Posts

How to make HTTP callout from LWC

Image
Hello Trailblazers, In this blog we are going discuss about HTTP callouts from Client-side controller in LWC. In Aura components we have Apex controller with AuraEnabled method which have code for HTTP callout in it. We call this Apex method on execution of some action and then send the response back to Aura component for processing. But with Lightning Web Components we can easily make callout from Javascript itself using fetch method. If you are not familiar with fetch method then please checkout this link . fetch method primarily takes 2 parameters as input which are endpoint and information about request which includes method type, header information , body of the request all in JSON format. fetch(endpont, { REQUEST_INFO}).then((response => response.json())).then((responseData) => {PROCESS_responseData_HERE}); Let’s start with the implementation. I am going to use Data Faker Heroku app for demonstration. In this example I will be focusing on getting data from third party so ...

Salesforce Platform Events

Image
Hello Trailblazers, In this article we will discuss about the platform events. This covers basic idea of Platform Events, how platform events work, how to use Platform Events and some considerations for using Platform Events. Salesforce Platform Events follow Event Driven Architecture. So what is event driven architecture? In simple words, whenever any kind of action happens you notify someone with some message, and we call that action as an Event , message that it carries is known as Event Message , someone who is going to receive that message is known as Event Consumer , environment where action has happened is Event Producer and common channel through which Producer sends an event and receiver reads message is known as Event Bus . This is completely different from request-response structure, your system/application just have to subscribe to event channel and they will be notified in real-time whenever event occurs. Receivers are always in listening mode and more than one receive...

Generic Custom Lookup Lightning Web Component

Hello Trailblazers,   In this blog I have created generic lookup component using LWC which can be used directly without changing single line of code. You just have to pass object name, fields to be retrieved and fieldname on which search operation should happen while using this component along with event handler method, that’s it you are ready to use record captured in lookup field. Which makes it available for use multiple times in single component.    This example contains below main  components :   1.        GenericLookup   – Apex class for querying records   2.        genericLookup   - LWC Main component - This you will be using as per your need   3.        recordListItem   - LWC to render suggested records   First lets  have a look at GenericLookup class Now create  recordListItem  component This component is...

VS Code Editor Setup For Salesforce

Image
Visual Studio Code is the latest IDE for Salesforce Development and believe me it has eased developer’s life by providing rich functionalities. This post will help you to setup VS code editor for Salesforce development.  Downloads : 1.        Visual Studio Code 2.        Salesforce CLI Installing VS Code Editor To download Visual Studio Code navigate to link given above. From download page select your operating system and proceed to download. I will suggest you to download most stable version of VS Code Editor. Once download is complete, install it in the system. Once installation is complete, you’ll see below welcome screen. While installing make sure to select Add To PATH option. Now let’s go ahead and download Salesforce CLI.   Installing Salesforce CLI Salesforce CLI is a command line interface that simplifies development and build automation.  VS Code ...

Debugging In Salesforce - Part II

Image
Hope you have read Part I of this series !! In this part we'll understand how to read log file. Once you capture a log file and open it, you can get all information from first line itself. First line of log gives information about the log categories and levels and   Second line gives User Information EXECUTION_STARTED marks the start of transaction. CODE_UNIT_STARTED and CODE_UNIIT_FINISHED marks start and end of particular code unit which was executed during transaction. Using this you can check what has happened when particular unit of code executed. Units of code include, but are not limited to, the following: Triggers Workflow invocations and time-based workflow Validation rules Approval processes Apex lead convert @future method invocations Web service invocations executeAnonymous calls Visualforce property accesses on Apex controllers Visualforce actions on Apex controllers Execution of the batch Apex start and finish methods, and each ex...

Debugging In Salesforce - Part I

Image
If you are ready to accept that your code can run into error, then debug logs can help you to find out the victim. Debug logs give all required information of a transaction to find out what is exactly happening when you perform any kind of action in Salesforce which includes database operation, system processes.You can set debug logs for users, classes and triggers. Before moving ahead with how to capture debug logs, let’s understand few related terms which we will use while setting debug logs :  When monitoring debug logs you can specify what you want track or capture in that file. For this Log Category and Log Level helps. Log Category :    With this you can mention what type of information you want to be logged, such as whether you want to get information about Apex or DML operations etc.            Below are the different log categories –         Category Description Database This gi...