Posts

Showing posts with the label Apex

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 ...