Category: Dr. SFDC Scout
-
How to force reset Password from backend
Sometimes you need to reset password from backend (i.e from Developer console). To do that, just run below code in anonymous window in Dev Console. Don’t forget to replace the ‘username@test.com’ and ‘CustomPW@1’ with the actual username and password. Syntax: System.setPassword(userid, password);
-
How to add Hyperlink in Custom Label
When we print label on UI the HTML tags gets escaped by default due to security reasons. But if you are aware its static text then its ok to unescape html Custom Label: In AURA:
-
How to Insert more than 10K records using Apex
Now this is very common use case and everybody will think of batch apex, which is obviously correct. But suppose you have below use case. When user insert an Account, you need to insert 15K related Contacts. Now this is tricky, why? Because for sure you will query Account in…
-
How to export Apex Test Class Coverage
If you want to export a report like below, then its very simple and in a minute you can get the same. Just follow below steps:
-
Dynamically Get Picklist Label & Values of any Object & Field in Salesforce
You can create a dynamic method to retrieve the picklist labels and values for any object and field in Salesforce. Here’s a dynamic method that takes the object API name and field API name as parameters: Now you can call the method to get the value. Like: Happy Learning 😊
-
How to get Picklist field API and Label both in Apex
This requirement can be achieved using Schema class. PFB one example UtilityClass which will return the API to Label mapping. PFB the Output:
-
Dynamic/Reusable Table in LWC (Salesforce)
Use-case: Suppose in your application you have 10 tables to show. So instead of writing code for each table, you can think of this dynamic/reusable table. Create Dynamic/Reusable Table Create a Custom Metadata Type named Table_Column_Metadata__mdt. Add fields to store column information such as API_Name__c (API name of the field),…
-
How to add straight line in LWC (Salesforce)
CSS will do the job. Sharing sample code. Component: CSS:
-
How to avoid recursion in Salesforce
Recursion is a major problem in applications. It’s always better to keep the Recursion in mind before you implement any business automation requirement. Sharing some of the general strategy to avoid/fix recursion: Apex Class Apex Trigger Static in Salesforce are per transaction, so the value will be true only for…