Month: August 2020

Winter ’21 Apex New Feature

 This post will cover some of my favorite Apex new features from Winter ’21. I have published another post that covered new existing enhancements for Flow Designer. To explore all the new features from Winter ’21 release, I highly recommend -Sign up to a pre-release org and explore all the new features.Post your findings in the Trailblazer Community and include the hashtag #Winter21Treasure to receive Trailhead Treasure Hunter badgeHere is the listSafe Navigation OperatorWith the introduction of Safe Navigation operator (?.), we are no more needed to perform an explicit null check to avoid NullPointer Exception. Basically, if the left side expression of the operator evaluates to null, then the right side will not be evaluated. //Before Winter’21List<Contact> allContacts = [ SELECT Id FROM Contact WHERE name = :contactName];if (allContacts.size() > 0) { String Id = allContacts.get(0).Id;}//After Winter’21String Id = [SELECT Id FROM Contact WHERE name = :contactName]?.get(0).Id;Update Resources with the PATCH HTTP Method in Apex CalloutsBefore Winter ’21 it was not possible to make a PATCH request from Salesforce. We always used the hack of using the PUT method to make it work. But with Winter ’21 we can now make PATCH metho in our HttpRequest class.Detect Apex Runtime Context with RequestId and QuiddityNow it is possible to detect Apex context at runtime and correlate multiple logs triggered by the request, using Request ID and Quiddity values.//Get info about...

Read More

Winter ’21 Flow Enhancements

 Winter ’21 pre-release org is ready. And without any surprise, Winter ’21 is also bringing lots of great enhancements. In this post, I am going to focus on a few Flow Enhancements that we will be getting soon and will be able to take advantage of. Handling Deletion Through Record Triggered FlowWith Winter ’21, we will be able to trigger a flow when the record is getting deleted. This is similar to Delete context from Trigger. To me, this is a great enhancement. Few things to note, you can. only do Before the record is deleted, not after the record is deleted. And if the deleted record is recovered later, that will not rollback any changes/actions performed as part of the flow. To handle that situation, the recommended approach is to write Apex after undelete trigger.Auto LayoutsWith this release, you will be presented with the option of selecting either a Freeform or Autolayout option. Autolayout is in Beta stage right now. But if you select Autolayout, you basically keep adding components by clicking on + sign. No need to organize and dragging here and there to make the flow look good, keep the connector line straight, etc. If you are like me, who likes to see things organized, I am sure you will like this feature as well.Debug Flow as Specific UserIf you feel frustrated with the complaint that flow...

Read More

Show Your Data in Datatable, Map or Tile Format Inside Flow

In this post, I am going to show you one of the most powerful AppExchange flow solutions built by Salesforce Labs. If you ever needed to display a collection of records in some format, mostly in datatable format to the user and provide options to the user to select records from that list and finally perform some actions based on those selected records, then this AppExchange pre-built flow solution is your going to be your friend. 😃Check out my youtube channel for more Salesforce Videos here.All about Salesforce Release – Spring 21 hereThe name of the solution is Flow Datagrid Pack. With this solution, you have the power now to display your collection of records in three different formats -Data Grid – Basically displays the records in a multi-select datatable.Tile Grid – Displays in multi-select (configurable) tiles format.Map Grid – Displays multi-select markers on map where you need to display records on the map. Ex: Display a list of accounts in Ontario within the map.Let’s configure this flow solution for a basic use case.Use Case:Need a solution where all the contacts from an account will be displayed in datatable and the user can select from the list. Based on the selected contacts, only those contacts should be displayed on the next screen.Solution – Flow:I build the below flow using the Flow Datagrid pack.Here are the steps -Fetch Associated ContactsIn this...

Read More

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

Configure Parcel in VS Code for JavaScript Development

In my previous posts, I have written down the steps which will help you to configure ESLint, Prettier, and Husky in Visual Studio Code to make your JavaScript development easy and making sure code syntax, as well as best practices, are being followed. If you haven’t seen that post, I highly recommend you go through that at – Configure ESLint and Prettier in VS Code for JavaScript DevelopmentConfigure Husky in VS Code for JavaScript DevelopmentToday I am going to talk about another important tool when you are dealing with creating packages for your JavaScripts project. It’s called Parcel.From this post, you can expect -Quick introduction of ParcelConfigure Parcel in Visual Studio CodeExamplesQuick Introduction of ParcelParcel is a web application bundler. It’s an alternative of webpack and comes with some different value propositions.The main features which come with Parcel are – Parcel makes sure to perform all the above without any configurations with speed. Pretty impressive, right. Configure Parcel in Visual Studio CodeStep 1 – Initiate npmWe can initiate npm by executing the command “npm init” from the terminal section of the Visual Studio Code. This will ask for a few questions which are very self-explanatory, but we can ignore them by just typing enter. Once the command executes, it will create the file package.json in the workspace.Step 2 – Install ParcelWe can install parcel as dev dependency by executing the command “npm install...

Read More

Earlier Posts

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