Sunday, 20 January 2019

Create Dynamic Picklists for Your Custom Components (design:component)


We can expose a component property as a picklist when the component is configured in the Lightning App Builder. The picklist’s values are provided by an Apex class that you create.

For example, let’s say you’re creating a component for the Home page to display an object records. You can use an Apex class to put the object Names of your Salesforce org in a picklist in the component’s properties in the Lightning App Builder. Then, when admins add the component to a Home page, they can easily select the appropriate object to display records on the page.

Usually we use <design:component/> to set default values for a component while adding it in App Builder. When we want to provide picklist to hold all objects for selection while adding we have to follow the things below.

  • Create a custom Apex class to use as a datasource for the picklist. The Apex class must extend the VisualEditor.DynamicPickList abstract class.
  • Add an attribute to your design file that specifies your custom Apex class as the datasource.
Apex Class

global class MyCustomPickList extends VisualEditor.DynamicPickList{
    global override VisualEditor.DataRow getDefaultValue(){
        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('account', 'Account');
        return defaultValue;
    global override VisualEditor.DynamicPickListRows getValues() {        
        VisualEditor.DynamicPickListRows  picklistRowsList = new VisualEditor.DynamicPickListRows();
        List<VisualEditor.DataRow> dataRowsList = new List<VisualEditor.DataRow>();
        for(Schema.SObjectType sobjectTypeName:schema.getGlobalDescribe().values()){
            VisualEditor.DataRow rowObj = new VisualEditor.DataRow(sobjectTypeName.getDescribe().getLabel(), sobjectTypeName.getDescribe().getName());
        return picklistRowsList;

Add the Apex Class to Your Design File
To specify an Apex class as a datasource in an existing component, add the datasource

        <design:attribute name="sobjectName" datasource="apex://MyCustomPickList"/>

Dynamic Picklist Considerations

  • Specifying the Apex datasource as public isn’t respected in managed packages. If an Apex class is public and part of a managed package, it can be used as a datasource for custom components in the subscriber org.
  • Profile access on the Apex class isn’t respected when the Apex class is used as a datasource. If an admin’s profile doesn’t have access to the Apex class but does have access to the custom component, the admin sees values provided by the Apex class on the component in the Lightning App Builder.

Saturday, 8 December 2018

Convert 15 character IDs to 18 character IDs in formula field

Hi ,

We have new method "CASESAFEID()"in formula field now to make 15 character Id to 18 character.

1. Go to Setup | Customize | object name | click Fields
a. For Custom objects: Setup Create Objects | object name
3. In the related list "Custom Fields & Relationships" click New.
4. Click the Formula radio button.
5. Click the Text radio button for 'Formula Return Type.'
6. Input the following Formula into the Formula Editor:

7. Set Field Visibility, add or remove from the page layout.
 8. Click Save.

1. Go to Setup Object Manager | Object name | Fields & Relationships
2. Click New.
3. Click the Formula radio button.
4. Click the Text radio button for 'Formula Return Type.'
5. Input the following formula into the Formula Editor:

6. Set Field Visibility, add or remove from the page layout.
7. Click Save.


Sunday, 25 November 2018

Run Script After Sandbox Creation and Refresh

Hi ,
We have an interface SandboxPostCopy from to do data manipulation after sandbox is created or refresh.
It makes our  sandbox environment business ready, automate data manipulation or business logic tasks.
At sandbox creation, specify a single Apex class to perform the tasks. This class executes every time the sandbox is copied.
Lightning interface of sandbox post-copy script specification

Create an Apex class that implements SandboxPostCopy and specify the class here. For example, the following Apex class simply reports the three contexts available in SandboxPostCopy: your organization ID, sandbox ID, and sandbox name:
global class HelloWorld implements SandboxPostCopy {
  global void runApexClass(SandboxContext context) {
      System.debug('Hello Tester Pester ' + context.organizationId()
           + ' ' + context.sandboxId() + context.sandboxName()); 

you can write your business logic in the method "runApexClass"


Monday, 19 November 2018

SFDX with Non Scratch Orgs

Hi ,

Gave demo on SFDX with Non Scratch orgs in our Salesforce Techbook Channel. You can learn how to use SFDX with Non Scratch orgs after this demo.

VS Code:
Salesforce Extensions:

Monday, 12 November 2018

Software installations for SFDX setup

Hi ,

We need to setup the following software in the order mentioned

1)Install Java8 (jdk 8)  and set path
2)Install SFDXCLI "" and set path
3)Install VS Code
4)Install "Salesforce Extension Pack" in VS code  (Under extensions section search for Salesforce Extensions for Visual Studio Code)


Sunday, 14 October 2018

Get Record Type Id from lightning component in standard new action override (getting any url parameter)

Hi ,

Here we have requirement to get record type id from lightning component when standard "New" action is overrided.

To get selected RecordTypeId from the component we have to implement the lightning interface "lightning:isUrlAddressable" which will be useful to access parameter "RecordTypeId" from the top level.


Ligthtning Component:

<aura:component implements="lightning:isUrlAddressable" description="c:helloTarget component">
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    Hello {!v.firstname}.

    init: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.RecordTypeId;
        cmp.set("v.firstname", firstname);


lightning:workspaceAPI on Lightning Console Applications (Getting record id from record tab)

Hi ,

To access tabs or sub tabs information in Salesforce Classic console application we have Console Integration Toolkit.
In the same way to access tabs or sub tabs information in Lightning Conosle Application we have to use "workspaceAPI".
To access methods of "workspaceAPI" we have to create an instance of the lightning:workspaceAPI component and assign an aura:id attribute to it as shown below .

<lightning:workspaceAPI aura:id="workspace"/>

This component allows you to access methods for programmatically controlling workspace tabs and subtabs in a Lightning console app. In Lightning console apps, records open as workspace tabs and their related records open as subtabs.

When a record is opened in Lighning Console application  we should be able to find out the record ID from the record tab, for further process from application utility menu items.


<aura:component                  implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable" 
                access="global"  controller="UpdateCaseController">
    <lightning:workspaceAPI aura:id="workspace" />

    <aura:attribute name="recordId" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>


doInit : function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getTabInfo().then(function(response) {
                       var action = component.get("c.updateCase");        
                             var result = data.getReturnValue();

Apex Controller:

public class UpdateCaseController{
   public static void updateCase(String caseRecordId){
       Case caseObj = new Case(Id=caseRecordId,ownerId=UserInfo.getUserId());
        update caseObj;



Saturday, 29 September 2018

Lightning Data Service Considerations (limitations)


We have few limitations on Lightning Data Service. We have to consider these before we use the same for any implementation.

Lightning Data Service is powerful and simple to use. However, it’s not a complete replacement for writing your own data access code. Here are some considerations to keep in mind when using it.
Lightning Data Service is only available in Lightning Experience and the Salesforce app. Using Lightning Data Service in other containers, such as Lightning Components for Visualforce or Lightning Out, isn’t supported. This is true even if these containers are accessed inside Lightning Experience or the Salesforce mobile app, for example, a Visualforce page added to Lightning Experience.

Lightning Data Service supports primitive DML operations—create, read, update, and delete. It operates on one record at a time, which you retrieve or modify using the record ID. Lightning Data Service supports spanned fields with a maximum depth of five levels. Support for working with collections of records or for querying for a record by anything other than the record ID isn’t available. If you must support higher-level operations or multiple operations in one transaction, use standard @AuraEnabled Apex methods.

Lightning Data Service shared data storage provides notifications to all components that use a record whenever a component changes that record. It doesn’t notify components if that record is changed on the server, for example, if someone else modifies it. Records changed on the server aren’t updated locally until they’re reloaded. Lightning Data Service notifies listeners about data changes only if the changed fields are the same as in the listener’s fields or layout.


Sunday, 26 August 2018

Salesforce Techbook (New Youtube Channel)

Hi ,

Have started new youtube channel "Salesforce Techbook" for providing useful examples.The following video published on "Salesforce Techbook" channel. Interested people can subscribe.

Please find the below URL (lightning component development):

Channel URL:

Future Concepts:

All the best

Interface Reference of Lightning

Implement these platform interfaces to allow a component to be used in different contexts, or to enable your component to receive extra context data. A component can implement multiple interfaces. Some interfaces are intended to be implemented together, while others are mutually exclusive. Some interfaces have an effect only in Lightning Experience and the Salesforce app.

Interfaces belong to different namespaces, including:

Provides interfaces that are specific to Lightning for Outlook or Lightning for Gmail.
Provides interfaces that are specific to Lightning Pages and the Lightning App Builder.
Provides interfaces that are specific to Lightning Experience and the Salesforce app.
Provides interfaces that are specific to Communities.
Provides interfaces that are specific to Lightning Experience, the Salesforce app, and Communities.
Provides events that are handled by Lightning Out.
Some of these interfaces are summarized below. For a complete list, refer to the Component Library.

To appear in the Lightning App Builder or a Lightning Page in Lightning for Outlook or Lightning for Gmail, a component must implement the clients:availableForMailAppAppPage interface. 
Enables a component to be assigned to an event’s date or location attributes in Lightning for Outlook and Lightning for Gmail. 
Enables a component to be assigned to an email’s or a calendar event’s item attributes in Lightning for Outlook and Lightning for Gmail.
A global interface that makes a component available in the Lightning App Builder, and for any type of Lightning page.
If your component is designed only for record pages, implement the flexipage:availableForRecordHome interface instead of flexipage:availableForAllPageTypes
To appear in Community Builder, a component must implement the forceCommunity:availableForAllPageTypes interface. 
Allows a component to be used as a custom tab in Lightning Experience or the Salesforce app. 
Allows a component to display in a panel with standard action controls, such as a Cancel button. These components can also display and implement their own controls, but should handle events from the standard controls. If you implement force:lightningQuickAction, you can’t implement force:lightningQuickActionWithoutHeader within the same component.
Allows a component to display in a panel without additional controls. The component should provide a complete user interface for the action. If you implement force:lightningQuickActionWithoutHeader, you can’t implement force:lightningQuickAction within the same component. 
Add the ltng:allowGuestAccess interface to your Lightning Out dependency app to make it available to users without requiring them to authenticate with Salesforce. This interface lets you build your app with Lightning components, and deploy it anywhere and to anyone. 


Thursday, 26 July 2018

Get the Developer Name for Record Types without SOQL query


Previously, the developer name was accessible only via SOQL on the RecordType SObject, and not via describe information. Now you can use the following methods to get the developer name.

  • Schema.DescribeSObjectResult.getRecordTypeInfosByDeveloperName()
  • Schema.RecordTypeInfo.getDeveloperName()

Sample Codes:

Getting Record Type Id based on Developer Name:

Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names of Department__c object
Map<String,Schema.RecordTypeInfo>  recordTypeInfo = resSchema.getRecordTypeInfosByDeveloperName(); 
//Getting IT Department Record Type Id by using developer name ''IT_Department"
Id recordTypeId= recordTypeInfo.get('IT_Department').getRecordTypeId();

Getting RecordType Developer Name based on Name(Label):

Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names Account
Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); 
//Getting Business Record Type Id by using developer name 
String developerName = recordTypeInfo.get('IT Department').getDeveloperName();



Create Dynamic Picklists for Your Custom Components (design:component)

Hi, We can expose a component property as a picklist when the component is configured in the Lightning App Builder. The picklist’s value...