Month: December 2020

Top Apex Features From Spring 21

Spring 21 is bringing a couple of Apex features that can be definitely helpful. This post will cover a few of my favorite Apex features from Spring 21.You can find all my Spring 21 release posts here.Feature #1With Spring 21, we can fetch the entire custom metadata records or a single record from the custom metadata. So no more SOQL query to fetch custom metadata records. Here is the video where I have explained the feature. With getAll() method, now we can get the entire custom metadata records. Here is the small code snippetpublic static void fetchAllMetadata() {    Map<String, Country__mdt> allCountries = Country__mdt.getAll();    System.Debug(‘allCountries Size: ‘ + allCountries.size());    for(String countrName : allCountries.keySet()){        System.Debug(‘Country Name: ‘ + countryName + ‘ Capital: ‘             + allCountries.get(countrName).Capital__c);    }}With getInstance( recordId ),  getInstance( qualifiedApiName ), getInstance( developerName ) method, now we can get the single custom metadata record. Here is the small code snippetpublic static void fetchCapital(String countryName) {    Country__mdt singleCountry = Country__mdt.getInstance(countryName);    System.Debug(‘Country Name: ‘ + countryName + ‘ Capital: ‘         + singleCountry?.Capital__c);}Feature #2With Spring 21, we can now convert 18-character Id to 15-character Id. Here is the video where I have explained the feature. With to15() method, now we can get the 15-character Id of the corresponding 18-character Id. Here is the small code snippet.public static void convertId(String id_18) {    ID test18 = id_18;    System.Debug(’15 Digit ID: ‘...

Read More

How to Run part of the Flow after the Triggering Event | Spring 21 New Feature

If you are a Salesforce Flow fan, I am sure like me, Spring 21 release is going to excite you as well. If you are dealing with situations where you need to take actions based on some future dates, till today, you can either write scheduled action in Process Builder or time-dependent actions in workflow rules. But with Spring 21 release you can implement the same in flow. This post will show you how you can take advantage of this new cool feature. I also created a video explaining the steps.You can check my other posts which talk about some of the flow enhancements that are coming along with Spring 21 release.How to compare between Prior and New Value in Record Triggered FlowsBlog: to create multi-column screens in Flow BuilderBlog: Case:Here is the use case which I will be implementing -Step 1Create a Record-Trigerred Flow and choose Freeform/Auto-Layout in the next screen. Step 2Configure the Trigger Screen as -Trigger the Flow When: A record is created or updatedRun the Flow: After the record is saved [Note – Schedule action/path is only available after the record is saved.]Step 3Configure the object as “Opportunity” with the criteria to make sure flow is running only when the opportunity is open.Important – Select “Only when a record is updated to meet the condition requirements” under the “When to run the Flow for updated records”...

Read More

How to Compare Between Prior and New Value in Record Triggered Flows | Spring 21 New Feature

 Spring 21 is going to be full of new Flow features. Today I will be explaining how you can compare between prior and new value in record triggered flows. In my earlier post, I have shared another feature from Spring 21 – “How to create multi-column screens in Flow Builder”. The video link is here.Before Spring 21, if we need to compare between prior and new values before running the business processes, we need to rely on either Process Builder or Trigger. But with the introduction of Spring 21 release, now we can do this comparison right inside flow builder and take actions accordingly.In this post, I will use this feature to implement a basic use case. I also put a short video here explaining the steps.Use CaseHere comes the use case which I will be implementing using flow.Step 1Create a Record-Trigerred flow and choose Freeform/Auto-Layout in the next screen.Step 2Configure Trigger screen, select -Trigger The Flow When: A record is created or updated.Run the Flow: Before the record is saved.Step 3In the Choose Object screen, select -Object: Opportunity.Condition Requirements: Amount Is null False.Step 4Create the decision where -Outcome – Greater Outcome – Less Than EqualStep 5Add the assignment for Greater to update the rating to HOT.Step 6Add the assignment for Less Than Equal to update the rating to NORMAL.FinalBelow is how the flow will look like finally -I hope...

Read More

How to Create Multi-Column Screens in Flow Builder | Spring 21 New Feature

Salesforce is bringing a new feature in Spring 21, which we all are waiting for a long time. It’s about creating Multi-Column Screens in Flow Builder.Before Spring 21, we had no/limited control to add multi-columns in flow screens. So to get that feature either we need to write web components or make some other changes(which involves coding). But the good news is that right after Spring 21, we can add multiple columns in the flow screens and no more custom coding is required (unless it is definitely something that can not be done in flow).In this blog post, I will show you how you can take advantage of this new feature. I also put a short video here where I have used this new feature.Step 1Create a Screen Flow and choose Freeform / Auto-Layout in the next screenStep 2Add the Screen Element in the canvas and add the Section (Beta) in the screen element. It will look like – Step 3Once you add Section (Beta) to the screen, on the right side, you will find a button to add columns. You can click and start adding columns. You can add upto four columns and also choose the width of each column.Width wise the entire width is divided in the unit of 12. Step 4You can add components in individual sections. Like I have below components as below -Column 1 – Text...

Read More

How to use Safe Navigation Operator (?.) in Apex | Winter 21 New Feature

 Salesforce rolled out a new feature in Winter 21 release, it’s called – SAFE NAVIGATION. Safe navigation operator is a very useful syntax for Salesforce Developers and it will make the coding clean. The main purpose of this syntax is to avoid null pointer exceptions.Basic SyntaxString accountName = accountRecord?.Name;The above statement will store accountRecord.Name value in the variable accountName. As you can understand that accountRecord is basically the sObject variable holding Account record and then we are using that variable to fetch the Name property. Now, what will happen if the accountRecord is null, then null.Name will definitely give the null pointer exception, right? But the answer is No. Because we have used the safe navigation operator(?.) here. Safe navigation operator will make the check and if the accountRecord is not null, then only store the Name field to accountName, otherwise, it will just store null there.How it works:If the left side of the chain expression (?.) evaluates to null, then the right side will not be evaluated. This safe navigation can be used in the method, variable, and property chaining. The part of the expression that is not evaluated can include variable and property chaining.Example 1:Let’s say we have a method that will take the AccountNumber as a parameter and print the AccountName.Before Winter 21 without Safe Navigation, our code will look like –    public static void getAccountNameWithoutSafeNavigation(String accountNumber){...

Read More

Earlier Posts

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