Category: Spring 20

Spring’20 Brings Improved Code Coverage Result for Apex Test Class

 Writing test classes to cover both positive, negative, and bulkified scenarios are always the best practices that each developer should follow. While writing test classes, our approach should be to cover as much as code and all the scenarios. There is a restriction from Salesforce that if there is not enough coverage (75%) for the code, then Salesforce will not allow you to deploy your code to production.So identifying the code coverage is very important. Now there are multiple ways we can get to know the code coverage like – Setup menu, Developer Console, SOQL Query, Salesforce CLI, or Salesforce extension in Visual Studio Code. With so many options there comes the difficulties. Each option presents the code coverage in a different way and more importantly, each option calculates code coverage in a different way. This always creates confusion. For example, when a developer writes the test class and executes that from CLI, it provides the code coverage, let’s say 90%, which should be good enough to deploy the code into Production. But while deployment, the code coverage came down to 50%, and thus deployment stops. The reason for this drop in code coverage is that while deploying code coverage is calculated at the org level i.e. percentage of coverage for that class across the org.To solve this problem, Salesforce comes up with the Enhanced Code Coverage option. With...

Read More

Spring’20 brings one Invocable method for all

 Have you ever asked this question to yourself – Why I have to write multiple invocable methods for the same functionality working on different objects? Definitely not a very clean approach. Thankfully Salesforce came up with the enhanced version of Invocable methods which now can work on multiple objects doing similar types of work. With this new enhancement, you can now write Invocable methods which will accept generic sObject data type. As a result, you will write one single Invocable method which will now work for multiple sObjects. The advantage is that if in your org, you have multiple Invocable methods doing similar operations (you just created them because they need to work on different sObjects), it the time to merge them to make a single Invocable method and make your org look clean.In this post, I am going to show the example of creating one Invocable method which will be used to create Lead and Account when calling from different flows.Here is the Invocable method:public class createRecords { @InvocableMethod( label = ‘Create Records’ description = ‘Update records or create new records’) public static List<myResponse> createRecords(List<myRequest> request){ List<SObject> records = new List<SObject>(); for(myRequest singleRequest : request){ records.addAll(singleRequest.records); } List<myResponse> response = new List<myResponse>(); myResponse singleResponse = new myResponse(); Schema.SObjectType sObjectType = records.get(0).getSObjectType(); if(sObjectType != null){ String listType = ‘List<‘+sObjectType+’>’; List<SObject> castRecords = (List<SObject>)Type.forName(listType).newInstance(); castRecords.addAll(records); upsert castRecords; singleResponse.records = castRecords; response.add(singleResponse);...

Read More

Compare Knowledge Articles – WoW Feature

In Spring’20, Salesforce introduced one feature which was pending for a long time and also got a good amount of vote in Idea Exchange.Recently while working with a customer who is trying to implement Lightning Knowledge, it was one of the top priority requirement. And I don’t want to do any custom development for this. But to my surprise, I saw that Salesforce already introduced this feature in Spring’20 as Beta.I was like …So thought of sharing this information here how we can use this great feature.Basically in the article layout all we need to do is include the Lightning component “Article Version Comparison” and then we can select the versions we want to compare. Screenshots are given below.This is very useful feature for the Approver to see the actual changes before taking any decisions. Also for the viewer also, they can see the changes between different versions(provided they have the permission to view versions of the...

Read More

Earlier Posts

  • 2024 (27)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)