• User Permission : User Permission specify what action user can perform and what feature user can access.Permission set controls the access of users.User permission and access setting are specified in permission set and profiles. What is Difference between Profile and Permission Set : The Key Difference between Profile and permission set is that Profile is […]

    Read More

  • Roll Up Summary fields are one of the most useful custom field types in Salesforce, but not when your object model is based on lookup relationships. You see this magic only works on objects which are related as master-detail. Now we use ProcessBuilder and Flows to achieve the Rollup Summary with Lookup Relationship.  Use Case […]

    Read More

  • An asynchronous process is a process or function that executes a task “in the background” without the user having to wait for the task to finish. We’ll typically use asynchronous apex for callouts to external system operations that require higher limits, and code that needs to run at a certain time.  The key benefits of […]

    Read More

  • Sell Faster and Better – Salesforce Winter‘20 Release Features 1. The RECYCLE BIN for Lightning The Recycle Bin in Lightning Experience works the same as it does in Salesforce Classic. The org’s Recycle Bin is called Org Recycle Bin. It Restores records by clicking Restore. Permanently delete records by selecting them and clicking Delete. You […]

    Read More

  • Determine Record Type on the basis of Picklist Value

    For security reasons, the Lightning Component framework places restrictions on making API calls from JavaScript code. Using a named credential for specific API calls allows to carefully and selectively bypass this security restriction.

    Business Case:

    Client wants to auto-populate record type on standard case creation page on the basis of selected picklist value by using lightning component.


    As we can’t make API calls directly from Lightning Components so we ended up with learning it’s quite a complex process. We had to create three independent things to get this done:

    • A connected App
    • An Auth. Provider
    • A Named Credential

    Step 1: Create Connected App like this:

    Note: Enter TEMP:VALUE for the Callback URL, we’ll change after auth. Provider creation.

    Step 2: Create Auth. Provider as per given below:

     Copy-paste the consumer key and customer secret from the connected tab that we created above. For the Default Scopes type “refresh_token full”. And click save. You get to this screen:

    Copy the callback URL and paste this value in connected app Callback URL.

    Step 3: Create Named Credentials:

    Enter the URL for the ORG but make sure it’s ***. my.salesforce.com then replace .my.salesforce.com as per given below.

    Step 4: Method to get Recordtype by picklist value.

    Suppose picklist name is Category below method received parameter as category label and return record typeid.

    public static String getRecordTypeIdForCategory(String categoryLabel) {

    // results will contain HTML encoded characters, like &

    categoryLabel = categoryLabel.escapeHtml4();

    String recordTypeId = null;

    Boolean foundMatch = false;

    List<Id> recordTypeIds = new List<Id>();

    //query all recordtypes of case object.

    for(RecordType r : [SELECT Id, DeveloperName FROM RecordType where sObjectType=’Case’ AND IsActive = True]){



    String host = System.Url.getSalesforceBaseURL().toExternalForm();

    Map<String, List<String>> mapCategoriesByRecordType = new Map<String, List<String>>();

    // create a map of Categories assigned to RecordTypes

    for(String rId: recordTypeIds) {

                Http http = new Http();

                HttpRequest request = new HttpRequest();

                Http h = new Http();

                String url = ‘callout:CallMeBack/services/data/v42.0/ui-api/object-info/Case/picklist-values/’ + rId + ‘/Category__c’;



                request.setHeader(‘Authorization’, ‘Bearer ‘+ UserInfo.getSessionId());

                HttpResponse response;

                response = http.send(request);

                if(response.getStatus() == ‘OK’)


                            Map<String, Object> meta = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());

                            List<String> categoriesList = new List<String>();


                                        for(Object o: (List<Object> )meta.get(‘values’)){

                                                    Map<String, object > temp = (Map<String, object>)o;




                            mapCategoriesByRecordType.put(rid, categoriesList);



    for (Id key : mapCategoriesByRecordType.keySet()) {

                if(foundMatch == false) {

                            List<String> typeCategories = mapCategoriesByRecordType.get(key);

                            if(containsIgnoreCase(typeCategories, categoryLabel)) {

                                        foundMatch = true;

                                        recordTypeId = key;




    return recordTypeId;



    After selecting category in below component this will redirect to standard case creation page with auto-populating record type.

  • lighting Web Components

    What is Lightning Web Component?

    Lightning Web Components is a new framework for building Lightning components. For Lightning Web Components development you need to setup SalesforceDX and VsCode as Lightning component are currently available in the Developer console. If you want to know more about lightning web component please check our webinar recording of “Introduction to Lightning Web Components”. In ApexHours Session we covered all below topic

    Why Lightning Web Component (LWC)

    • Part 1 – Vanilla HTML5 Web Components
      • Benefits of Web Component
      • Pillars of Web Component
      • Demo of Custom Element and Templating 
    • Part 2 – Lightning Web Component
      • Hello World
      • Demo of Lifecycle methods
      • Call Apex Class
      • Access Custom Label
      • Lightning Data Services
      • Communication between Lightning Component and LWC

    Let see how to create very First Lightning Web Component.

    Step 1) Setup SalesforceDX with VSCode.

    Install Salesforce CLI. Here is link for download. You can take help from this post.

    Download and Install Salesforce VsCode. Here is the link to download.

    Install required Extension

    Step 2) Upgrade to Pre-Release org

    Sign up for a pre-release Developer Edition at https://www.salesforce.com/form/signup/prerelease-spring19/

    Upgrade Pre-Release version of Salesforce CLI

    sfdx plugins:install salesforcedx@pre-release

    Step 3) Create SalesforceDx Project

    1) Create ProjectIn out last post we talk about how to use SalesforceDx with non-scratch org. We will create project here with same steps.

    Press “CTRL+SHIFT+P” then select  “SFDX:Create Project with Manifest”

    2) Authorize your org

    Press “CTRL+SHIFT+P” then select  “SFDX: Authorize an Org”

    Step 4) Finally Create your first Lightning Web Component

    Press CTRL+SHIFT+P then Type Web Component and then select “SFDX: Create Lightning Web Component”

    • Then Select Folder where you want to save your LWC component
    • Then provide Component Name.
    • Verify your components under lwc folder

    Directory Structure 

    Step 6) Coding part for Lightning component



        <lightning-card title=”HelloWorld” icon-name=”custom:custom14″>

            <div class=”slds-m-around_medium”>

                <p>Hello, {greeting}!</p>

                <lightning-input label=”Name” value={greeting} onchange={changeHandler}></lightning-input>





    import { LightningElement, track } from ‘lwc’;

    export default class HelloWorld extends LightningElement {

        @track greeting = ‘World’;

        changeHandler(event) {

            this.greeting = event.target.value;


    <?xml version=”1.0″ encoding=”UTF-8″?>

    <LightningComponentBundle xmlns=”http://soap.sforce.com/2006/04/metadata” fqn=”helloWorld”>









    Step 6) Deploy your component in Org.

    Once you are done with code. Select LWC folder and right click on same then from menu select “SFDX: Deploy Source to Org”.

    Step 7) Verify your Changes with App Builder.

    Open your app builder and add your Custom Component on page/App