Posts

Error Logging Framework in Salesforce

Image
In Salesforce, to check for the errors, we do use debug logs. But the issue arises because we don't have access to logs when there is error in production. Many of the errors are even hard to replicate in production. Also the standard debug log hits the storage limit in production. Also if we delete some logs, it might delete those logs which would have been important to others. So here we are going to see a way to store the errors in SFDC so that users at any point of time in future can see and work upon them, without facing any of the issues mentioned above. So to start with we will create a custom object named : Log__c Then we will create the following custom fields of this object : 1. Log_Number__c : Auto Number 2. Exception_Cause__c : Long Text Area 3. Exception_Message__c : Long Text Area 4. Exception_Type__c : Text 5. Line_Number__c : Number 6. Stack_Trace__c : Long Text Area 7. Execution_Context__c : Text Then create custom Metadata i

How to implement client side pagination in LWC ?

Image
In this article, we are going to see how to implement client side pagination in LWC. Let say you have got requirement to get contacts from apex controller and display it in a table. But the catch here is there are 100s of records and now you have got the task to implement pagination such that you can also control how many records can be shown in the table from component only. So let's begin 1.Let's say we have got apex controller as below : @AuraEnabled(cacheable=true) public static List getMContact(String uId){ List cList = new List (); system.debug('The user Id is '+uId); User ug = [Select Id,Contact.AccountId from User WHERE Id =: uId LIMIT 1]; if(ug != null){ cList = [Select Id,Name,Phone,BirthDate,Email,MobilePhone,Role__c,is_Active__c from Contact WHERE AccountId =: ug.Contact.AccountId]; } system.debug('the count is '+cList.size()); return cList; } 2. Now

Update Custom Fonts in Salesforce Experience/Community Site

Image
So we are going to see how we can update the custom fonts on Salesforce Experience Site. If we want to change the fonts, we have a set of fonts that are available in the community site that we can choose from. But in case if we want to get a new font style we can follow the process.   1. Download the .ttf file of the font that you want in your experience site.   2. Upload the file in the Static Resource. 3.   Then go to Setup > All Sites > Builder (of site in which font is to be added). 4.   Then select Themes as shown in the image below. 5.  Select the drop-down and the click on Edit CSS as shown below. 6.  Here enter the code as metioned below. 7.  Font-family is the alias name given to the font with the help of which we will select the custom font later. Then in the src :  url(‘/sfsites/c/resource/  will be as it. Then we will enter the name of static resource which we had created earlier and in the end we will enter our filename. 8.  This will be followed by  format(‘truetyp

How to create Connected App in Salesforce and get access Token?

Image
  The Connected App is created to make authenticated calls to REST API in salesforce to perform CRUD (Create, Read, Update and Delete ) operations on records in Salesforce. To create a connected app follow the steps below : Go to App Manager in Setup and click on New Connected App 2. Fill out all the details as shown below with valid mail Id. In callback URL, you can enter any URL where you want to redirect after successful result. OAuth Scope has been provided as Full Access. You can modify it according to your requirement. Then save it. 3. Then on the Connected App record that we have created, click on Manage > Edit Policies > Permitted Users. Set it to All users may self-authorize. Also if you have got some IP ranges set in your org, you can set IP Restriction to Relax IP restriction. 4. Then in Setup go to My Domain and note down the domain name. 5. Then we will go back to Connected App record that we had created and note down the client_id and client_secret from there which