Introduction to Lightning Web Components – #LWC

As we all know that Salesforce has introduced the new concept to develop the Lightning Components which is LWC and is beta mode. In this post, we are going to learn how we can start working with LWC and all about LWC

I have recorded the videos regarding the same how we can set up the VS Code to start the coding with Salesforce DX. As, LWC is in beta mode and not available either in Sandbox or Developer environment we need to work with Salesforce Spring 19 Pre-Release Org. Here is the video which will take you to step by step how you can set up the tools and start development.

  • What is LWC?
  • Existing System
  • New LWC Structure
  • Comparison of Aura Framework and LWC
  • Setup Visual Code studio
  • Setup Salesforce CLI
  • Create Hello World LWC
  • Walkthrough with the key concept of LWC

Next Step – What the next video

  • LWC Folder Structure.
  • Supported Salesforce Experiences and Tools
  • Unsupported Experiences and Tools
  • Reactive Properties in JavaScript.
    • Public
    • Private
  • How to use attributes in LWC.
  • How to call the JavaScript method from LWC.

Sharing is Caring ūüôā If you have any doubt or query please comment them below in the comment box or you can reach me @ OR you can tweet me @cloudyamit

Things to keep in mind while developing the Salesforce App-exchange Application

In this post, I will discuss what are the important parameters that need to be taken care while developing the App-Exchange Application using Salesforce. Before we dive into the concepts I would like to tell you that after developing the application, every application goes with the below security checks

  1. Checkmarx: – It is a free tool available to scan the Complete Code that is in your org where development has been done.
  2. Security Review: – The second step after submitting the code to the checkmarx and resolving all the issues is to Submit the package for the security review where salesforce representatives check the Quality of the code and functionality as well.

So, In order to develop the application which is secure and minimize the risk of data compromise or any other confidential information a developer must need to keep the following points into the mind while developing the application

1. Cross-Site Scripting 
2. S(O)QL Injection 
3. Cross Site Request Forgery 
4. Secure Communications and Cookies 
5. Storing Secrets 
6. Arbitrary Redirects 
7. Access Control 
8. Lightning Security Best Practices 
9. Marketing Cloud App Security
10. Secure PostMessage
11. Secure WebSockets

Here is a Link to Trailhead module which explains everything about secure coding guidelines with the practical example

Resources: –¬†

  1. Salesforce Document
  2. Salesforce Security Guide
  3. An Overview of Security

Implement Omni Channel from Scratch – Salesforce

In this post, we will learn how to implement Omni Channel and in my previous post, we have implemented the Live Agent if you have not read yet then Read Here.

Prerequisite: Live agent must be enabled in order to use Omni Channel.


Problem while using Live Agent: РThe company XYZ has now successfully enabled the live agent at their company site and it was working fine however as business growing company  the Global Support VP is getting complaints

  1. Some agents are getting many cases and some are not getting any cases at all.
  2. Agents need to Case manually from the Queues if the case is created manually or any other resource like Email-to-Case. And assigning the cases manually leads the wastage of time.
  3. Also, it is hard to manage what is the capacity of the particular agent and what is the traffic. 

Salesforce Admin has come up with an idea to implement the Omni Channel which will resolve all above problem and will increase the efficiency of the Support Agent.


Introduction to Omni Channel:-¬†Omni-Channel is a flexible, customizable feature, and you can configure it declaratively‚ÄĒthat is, without writing code. Use Omni-Channel to manage the priority of work items, which makes it a cinch to route important work items to agents quickly. Manage your agents‚Äô capacity to take on work items so that they‚Äôre given only the number of assignments that they can handle.

Best of all, Omni-Channel routes all these assignments to the correct agents automatically. Agents no longer have to pick and choose work assignments manually from a queue, which saves everyone in your call center time, effort, and brainpower.

Permission to set up the Omni Channel is Customize Application at profile level.

Omni Channel.png

Step1 РEnable Omni Channel:- Setup -> Build -> Customize -> Omni-Channel -> Omni-Channel Settings -> Select Enable Omni-Channel Checkbox -> Save

Enable Omni Channel.png

Setp2 – Create Service Channel:-¬†Service Channels let you turn any Salesforce object‚Äēsuch as a case, lead, SOS session, or even a custom object‚Äēinto a work record. Omni-Channel then plucks these work items from their queues‚Äēlike flowers from the garden of agent productivity‚Äēand routes them to your agents in real time.


Setup -> Build -> Customize -> Omni-Channel ->  Service Channels -> New -> 

Service Channel.png

Step3 – Create¬†Routing Configurations: –¬†Routing Configurations determine how work items are routed to agents. They let you prioritize the relative importance and size of work items across your Omni-Channel Queues.¬†That way, the most important work items are handled accordingly, and work is evenly distributed to your agents. After all, we want to make sure every agent gets to have an equal amount of fun, right?

Setup -> Build -> Customize -> Omni-Channel -> Routing Configurations -> New -> 

Routing Configurations.png

Explanation of above Screenshot

  1. Overflow Assignee:- Sets the user or queue that Omni-Channel routes items to when your org reaches Omni-Channel limits.
  2. Routing Priority: –¬†The order in which work items from the queue that are associated with this routing configuration are routed to agents.
  3. Routing Model: Specify how incoming work items are directed to agents using Omni-Channel.
    1. Least Active: –¬†Incoming work items are routed to the agent with the least amount of open work.¬†
    2. Most Available: –¬†Incoming work items are routed to the agent with the greatest difference between work item capacity and open work items.¬†

Step4 – Create¬†Queue and Associated with Routing Configurations: –¬†

Setup -> Administrator -> Manage Users -> Queues -> New ->

Create Queue.png

Step5 – Add Omni Channel to the Console Application: –¬†

Setup -> Create -> Apps -> Edit Next to Sample Console App(OR You may Select your) -> Scroos Down to “Choose Console Components” Section -> Add Omni Channel From “Available Items” to “Selected Items”

Add Omni Channel.png

Now, as we have done almost part of implementing the Omni Channel. Let’s have a look how our console application looks like

Click on App Launcher and Select Sample Application


Step6 – Add Presence Status to Omni Channel: –¬†

To see the list of available status like Online, Offline, Away, Available For Cases, Available For Chat and etc. We need to create the Presence Status.

Setup -> Build -> Customize -> Omni-Channel -> Presence Status -> New -> 

Presence Status

Repeat the above process to add more presence status.

Step7 – Add Presence Status to Correct Users Profile: –¬†

Adding the presence status to the Omni Channel that does not mean it will be available in Omni Channel Utility. To make visible these statuses we need to add to the appropriate user’s profile or permission set.

Setup -> Manage Users -> Profiles -> Select the profile on which you want to enable the status (in this demo we will add in System Administrator Profile)->¬† Scroll down to “Enabled Service Presence Status Access”¬† section and Click Edit ->¬†

Presence Status to profile.png

Add presence status from “Available Service Presence Statuses” to “Enabled Service Presence Statuses” Section and save.

Add Presence Status to profile

Step8 – See if presence status is available in Omni Channel utility or Not: –¬†

Click on App Launcher and Select Sample App

Omni Channel Sttus.png

Now, in Final let us test the App. Copy and paste the code if Live Chat Deployment and Chat Button that we did create in our previous post and save as .html file. if you have not implemented the Live Agent refer this link to implement the same.

From Omni channel Select any online statue and run the HTML file of Live Agent that we did save earlier.


OutPut 1.png

If you are facing any issues please come up in the comments section with.

Sharing is Caring ūüôā


  1. Live Agent
  2. Omni Channel
  3. Trailhead




Dynamic Binding Salesforce Lightning Component(Generic)

Welcome back All, here we will learn about the dynamic field of Lightning Component. As Most of you must be aware of that In Lightning, Component Dynamic component is not available. Recently I was working on one of my projects and implemented the Dynamic binding using the lightning component so I am going to share how I implemented the same so that it may help others.

As we all know that we can use the Dynamic Binding in the VisualForce page but in Lightning Component it is not Possible. 

In this example, We will show the list of Objects in a picklist and when user will select any object it will dynamically show the TOP 15 records in a table.



Step1 – Create Apex Class


Step2 – Create the Lightning Component


See the comments into the component.

Step3: – Click on Controller from the right and paste the below code for Controller Javascript


doInit : function(component, event, helper) {
helper.onInit(component, event, helper);
doHandleChange : function(component, event, helper) {
helper.onHandleChange(component, event, helper);

Step4: – Click on Helper from the right and paste the below code for Helper Javascript


onInit : function(component, event, helper) {
/* Call the Apex class method to fetch the List of all object */
var action = component.get('c.listAllObject');
action.setCallback(this, function(response){
var state = response.getState();
if(state === 'SUCCESS' && component.isValid()){
/* set the value to the attribute of the component */
var responseValue = response.getReturnValue();
var lstOptions = [];
for(var i=0; i < responseValue.length; i++){
value : responseValue[i].split('####')[1],
key : responseValue[i].split('####')[0]
component.set('v.objectList', lstOptions);

var errors = response.getError();
if(errors || errors[0].message){
onHandleChange : function(component, event, helper){
/* Call this method whenever user will select the Obejct
* and show the Dynamic Content */
var selObject = component.find('selectObject').get('v.value');
var action = component.get('c.listAllFields');
if(selObject!=null && selObject!='' && selObject!=undefined){
"objectName" : selObject
action.setCallback(this, function(response){
var state = response.getState();
if( state === 'SUCCESS' && component.isValid()){
var responseValue = response.getReturnValue();
var objectValue = responseValue.sObjectData;
var fieldList = responseValue.fieldList;

/* Create Dynamic Table */
var sObjectDataTableHeader = [];
// Create table Header
for (var i=0; i < fieldList.length; i++) {
//Get the count of columns.
var columnCount = sObjectDataTableHeader.length;
//Create a HTML Table element.
var table = document.createElement("TABLE");
//table.border = "1";
//Add the header row.
var row = table.insertRow(-1);
for (var i = 0; i < columnCount; i++) {
var headerCell = document.createElement("TH");
headerCell.innerHTML = sObjectDataTableHeader[i];
var dvTable = document.getElementById("sfdctable");
dvTable.innerHTML = "";
/* Create Dynamic Table End */

for(var j=0; j < objectValue.length; j++){
// Dynamic table Row
row = table.insertRow(-1);
// Dynamic Table Row End
for (var i=0; i < fieldList.length; i++) {
// Dynamic table Row
var cell = row.insertCell(-1);
cell.innerHTML = objectValue[j][fieldList[i].apiName];
component.set('v.isSending' , false);


var errors = response.getError();
$A.log('Error Details '+errors);
if( errors || errors[0].message){
console.log('Error Details '+errors[0].message);
component.set('v.isSending' , false);

See the comments.

Step5: – Create Lightning Application

<aura:application access=”Global” extends=”force:slds” >
<c:DynamicBindingDemo />

Click on Preview to see the output of the component.

Happy learning ūüôā

Sharing is caring ūüôā ūüėČ



Complete Code




How to implement Live Agent into Salesforce From Scratch

To Create a Basic Live Agent Implementation into Salesforce we need to follow the 7 easy steps that are given below:

Step1 – Enable Live Agent: In order to enable Live agent user must have Customize Application permission

  1. From Setup in Salesforce Classic, enter Live Agent Settings in the Quick Find box, then select Live Agent Settings.
  2. Select Enable Live Agent.
  3. Click Save.

Enable Live Agent.png

Step2 – Create Live Agent Users :

  1. From Setup in Salesforce Classic, enter Users in the Quick Find box, then select Users.
  2. Click Edit next to a user’s name.
  3. Select Live Agent User. If you don’t see this checkbox, verify that your support organization has purchased enough Live Agent feature licenses.
  4. Click Save.

Create Live Agent Users.png

Step3 – Create And Assign Live Agent Skills :

  1. From Setup, enter Skills in the Quick Find box, then select Skills.
  2. Click New.
  3. Enter a name for the skill.
    For example, you can create a skill that‚Äôs called ‚ÄúAccounts‚ÄĚ for agents who specialize in questions about customer accounts.
  4. In the Assign Users area, select the users whom you want to associate with the skill.
  5. In the Assign Profiles area, select the profiles that you want to associate with the skill.
  6. Click Save.
To enable supervisors to assign skills, enable the ‚ÄúAssign Live Agent Skills to Users‚ÄĚ permission on their profiles.
Create Skills.png
Step4 – Create Live Agent Configuration :
  1. From Setup in Salesforce Classic, enter Live Agent Configurations in the Quick Find box, then select Live Agent Configurations.
  2. Click New.
  3. Choose the settings for your Live Agent configuration.
  4. Click Save.

Step5 – Create Live Agent Deployments :

  1. From Setup in Salesforce Classic, enter Deployments in the Quick Find box, then select Deployments.
  2. Click New.
  3. Choose the settings for your deployment.
  4. Click Save. Salesforce generates the deployment code.
  5. Copy the deployment code, and then paste it on each Web page where you want to deploy Live Agent. For best performance, paste the code immediately before the closing body tag (that is, ).


Step6 – Create Chat Button :

  1. From Setup in Salesforce Classic, enter Chat Buttons in the Quick Find box, then select Chat Buttons & Invitations.
  2. Click New.
  3. Select Chat Button from the Type field.
  4. Choose the remaining settings for your chat button.
  5. Click Save.
  6. Copy the button code, and then paste it on each Web page where you’ve deployed Live Agent. Make sure that you paste the code in the area on the page where you want the button to appear.

If you have any problem then please come up into comment section with


Salesforce Atricle


How to Call Salesforce API from Lightning Component

You may have heard about that we can not make the Salesforce API Call directly from the lightning component. If you do make the callout from the lightning component then you will get the below error

INVALID_SESSION_ID:This session is not valid for use with the API.

For Example when you will execute the below code from the Developer Console then you will get the Valid Response

HTTP h = new HTTP();
HTTPRequest req = new HTTPRequest();
HttpResponse resp = new HttpResponse();

req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v41.0/query?q=Select+Id,+Name+From+Account');
resp = h.send(req);
System.debug('#### Response Status '+resp.getStatus());
System.debug('#### Response Status Code '+resp.getStatusCOde());

But if you will call the same block from the Lightning Component then you will get INVALID_SESSION_ID:This session is not valid for use with the API. Error.

I gone through with this error and found THIS SALESFORCE DOCUMENT where they have specified why we can not make API Call from JavaScript Code.

After reading the document, I have come up with 2 Solutions that are given below: –

1 РConnected App and Named Credentials as Callout Endpoints and Auth Providers

2 – Using VF Page – VF page will be used to get the Session Id of the current log in user and this VF page will be used into Apex class for fetching the Session Id.

In this tutorial we will use VF page for making callout because it is an easy and simple method method. Follow the below steps

Step1 – Open Developer Console, File -> New -> VisualForce Page -> Enter Name “GetSessionIdVF” -> OK. Use below code for VF Page

<apex:page >

Step2 – Create a New Class which will use this VF page to get the Session Id and making API Call Out. File -> New -> Apex Class -> Name it “ApiCallLightningComponent” -> OK. Use below code for the class.

public class ApiCallLightningComponent {
 * @Name : - fetchUserSessionId
 * @Description: - Call the VF page and get the Log In Use Session Id
 * @Params : - none
 * @ReturnType : - String
 public static String fetchUserSessionId(){
 String sessionId = '';
 // Refer to the Page
 PageReference reportPage = Page.GetSessionIdVF;
 // Get the content of the VF page
 String vfContent = reportPage.getContent().toString();
 System.debug('vfContent '+vfContent);
 // Find the position of Start_Of_Session_Id and End_Of_Session_Id
 Integer startP = vfContent.indexOf('Start_Of_Session_Id') + 'Start_Of_Session_Id'.length(),
 endP = vfContent.indexOf('End_Of_Session_Id');
 // Get the Session Id
 sessionId = vfContent.substring(startP, endP);
 System.debug('sessionId '+sessionId);
 // Return Session Id
 return sessionId;
 * @Name - makeAPICall
 * @Description - Responsible for making API Call out
 * @params - None
 * @ReturnType - String
 public static String makeAPICall(){
 String sessionId = fetchUserSessionId();
 HTTP h = new HTTP();
 HTTPRequest req = new HTTPRequest();
 HttpResponse resp = new HttpResponse();
 req.setHeader('Authorization', 'Bearer ' + sessionId);
 req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v41.0/query?q=Select+Id,+Name+From+Account');
 resp = h.send(req);
 System.debug('#### Response Status '+resp.getStatus());
 System.debug('#### Response Status Code '+resp.getStatusCOde());
 return JSON.serialize(resp.getBody());

See the comments.

ApiCallLightningComponent class contains 2 methods fetchUserSessionId and makeAPICall, One for getting the Session Id and Other for making the Callout that will be called from the JavaScript.

Step3 – Create a lightning component, File -> New -> Lightning Component -> Name it “MakiAPICall” -> OK. Use below code for the Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes, flexipage:availableForRecordHome,force:hasRecordId, forceCommunity:availableForAllPageTypes, force:lightningQuickAction" controller="ApiCallLightningComponent" access="global" >
<div class="slds-m-around_x-small">
			<lightning:button variant="brand" label="Make CallOut" iconName="action:apex" iconPosition="left" onclick="{!c.doHandleClick }" /></div>

Click on the Controller and use below code

doHandleClick : function(component, event, helper) {
helper.onHandleClick(component, event, helper);

Click on the helper and then use below code for helper

onHandleClick : function(component, event, helper) {
// Get the action of Controller (Apex) Class
var action = component.get('c.makeAPICall');

// set the callback which will return the response from apex
action.setCallback(this, function(response){
// get the state
var state = response.getState();
if( (state === 'SUCCESS' || state ==='DRAFT') && component.isValid()){
// get the response
var responseValue = response.getReturnValue();
// Parse the respose
var responseData = JSON.parse(responseValue);
} else if( state === 'INCOMPLETE'){
console.log("User is offline, device doesn't support drafts.");
} else if( state === 'ERROR'){
console.log('Problem saving record, error: ' +
} else{
console.log('Unknown problem, state: ' + state +
', error: ' + JSON.stringify(response.getError()));
// send the action to the server which will call the apex and will return the response

Step4 – In Final Step Test the Component using Lightning Application. File -> New -> Lightning Application -> Enter Name -> Submit -> Use below Code

<aura:application extends='force:slds' >

Note: – If Your component name is different then use the name of your component instead of MakiAPICall.

Output of the above code

Call API From Lightning Component

You can find the complete Here.

Happy Learning ūüôā

Happy Coding ūüėČ

Sharing is Caring

Resources –


Salesforce Lightning Interview QA

I have compiled some Interview Questions related to Salesforce Lightning that are given below:

1 – One User is viewing a Lightning Component in which some fields are being displayed and in the mean time some other user have changed the value of the field. How do you ensure that user will see the updated value?

Answer – Using platform event. Streaming API will not work into the Lightning Environment.

2 –¬†What is Lightning Data Service(LDS) ? What are the benefits of using LDS?

Answer – LDS is a standard controller for Lightning Component. Using Lightning Data Service we can Create, Retrieve, Delete and update records for which we do not need to write the apex class. Lightning Data Services ensures the FLS by itself. For more info see Here.

3 – When we can not use LDS in Lightning Component?

Answer – LDS is used for single record so when we are dealing with Bulk records then we can not use LDS.

4 – What is main difference between Lightning Component and Visual Force Pages OR Why we should go for Lightning Component?

Answer – Visualforce components are page-centric and most of the work is done on the server. Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile friendly.

5 – Will Lightning Components be replacing Visualforce?

Answer – No.

6 – Is Lightning an MVC framework ?

Answer – No, it’s component based framework.

7 – What aura:method does in Lightning Component?

Answer РWe can Use aura:method to define a method as part of a component’s API. This enables us to directly call a method in a component’s client-side controller instead of firing and handling a component event

8 – How many Components can be used in a single lightning application?

Answer – There is no Limit.

9 – Will Visual Force page will stop working on Lightning UI?

Answer – No, VF page will work in the Lightning UI as Classic UI.

10 – Can we include external Library into Lightning Component?

Answer – Yes, we can include multiple library into Lightning component.

More QA updates soon ūüôā

Salesforce – Quickbooks Online Integration – oAuth 2.O

Hi All, Hope you all enjoyed my previous Integration related posts. I have come up with another integration. In this post we will make connection between Salesforce and Quickbook System using Apex, VF page.

Earlier Quickbooks uses oAuth 1.0 for the authentication but now it has updated it’s API and using oAuth 2.0 so in this Integration we are going to use oAuth 2.0

Step1 – Create a Custom Object OR Custom Metadata to store the information about Access and Refresh Token. If you are thinking about to use Custom Setting the answer is No because Access Token length is more than 255 Character and in Custom Setting we can store data upto 255 Character.

Setup -> Create -> Objects -> New -> Your Object will look like below image

QuickBooks Infos Object

Step2 – Create a Trail Account of QuickBooks From Here.

Step3 – Create a connected App into QuickBooks Developer account, Follow the steps given into this Link. Please enter a redirect URI. for example if you want to redirect into “QuickbookConnection” VF page and your org base URL is “; then your Redirect URI will be as given below


Step4 – Now, in this Step get the Consumer Secret and Consumer Key and to get the key follow the steps given in This Link.

Connected App

Step5 – Now, Create a Apex Class. File -> New -> Apex Class -> Name it “QuickbookConnection” -> OK. Use below code the class

Step5 – Create a VF page. File -> New -> Visualforce Page -> Name “QuickbookConnection” -> OK. and use below code for this page

&lt;apex:page controller="QuickbookConnection"&gt;
&lt;apex:slds /&gt;
&lt;apex:form id="theForm" &gt;
&lt;apex:pageblock &gt;
&lt;apex:pageMessages &gt;&lt;/apex:pageMessages&gt;
&lt;apex:actionstatus id="statusAuthQuickBooks"&gt;
&lt;apex:facet name="start"&gt;
&lt;div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;"&gt;
&lt;div class="waitingHolder" style="top: 100px; width: 91px;"&gt;
&lt;img class="waitingImage" src="/img/loading.gif" title="Please Wait..." /&gt;
&lt;span class="waitingDescription"&gt;Loading...&lt;/span&gt;&lt;/div&gt;
&lt;apex:pageBlockButtons location="top"&gt;
&lt;apex:commandButton action="{!doAuthorizationQuickBooks}" value="Authorize with Quickbooks" /&gt;
&lt;apex:commandButton action="{!doFetchAccessToken}" value="Complete Authorzation" status="statusAuthQuickBooks"
reRender="theForm" /&gt;

tada we have done with the coding and configuration part, now time to test the functionality. Click preview on the VF page. Click on Authorize with QuickBooks it will take you to login page of QuickBooks login with your username and password.

If you have more than 1 Sandbox it will list all the sandbox over there select one which you want to integrate.

Authorize the Application and you will be redirected to the same page now click on Complete Authorization it will create a record for the custom Object that you have created with success message

See the working in below gif Image

Salesforce - Quickbooks Working.gif

Now, We have access token we can make the callout to get the data from QuickBooks into Salesforce. You can find the complete code form Here.

If you have any problem then please come up into comment section.

Happy Learning ūüôā ūüėČ

Resources –

URLFOR Function Explained – Salesforce

URLFOR Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
This can be used to return a reference to a file contained in a static resource archive (such as a .zip or .jar file). Below is the Syntax Overview of URL for function

{!URLFOR(target, [id], [inputs], [no override])} 

Below is the description of all the attributes in detail:

Target: Action, or any static resource for image or Javascript.

Id : Name that is Of String or record ID (depends on the “target”).

parameters: Additional parameters passed. Format: [parameters1=”value1″, parameters2=”value2″, parameters3 = value3]

no override: A Boolean flag. Set to true if to display a standard Salesforce page     regardless of whether you have defined an override for it (default false)  [nooverride=1] OR [nooverride=0] OR [nooverride=true] OR [nooverride=false]

The input values can be dynamic. For example, to include an account ID, specify:
{!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])}

Edit –¬†URLFOR($Action.Account.Edit, Account.Id, [nooverride=1])

View –¬†URLFOR($Action.Account.View, Account.Id)

New¬† –¬†URLFOR($Action.Account.New)

Delete – URLFOR($Action.Account.Delete, Account.Id)

List View –¬†URLFOR($Action.Account.Tab,$ObjectType.Account)

Image –¬†<apex:image url=”{!URLFOR($Resource.redflag)}” height=”50″ width=”50″ />

Note: – Some Object may have different OR more action for those Object you can find using.

Standard Object 

Setup -> Customize -> Object Name -> Button Links and Action 

Custom Object

Setup -> Create -> Objects -> Find Your Object -> Button Links and Actions

In General You can use the below Syntax $Action.sObjectType.Name

$Action – Defined the action

sObjectType – API name of the Salesforce Object

Name – Name of the Action that may be Edit, New, Edit and Delete, etc..


Here is a sample VF page for account Object, to see preview of the VF page append record Id of account Object into the URL like below in Red Color


Happy Learning ūüôā ūüėČ

Call Child Component Controller From Parent Component – Aura Method

In my previous posts we have seen how we can use application and component events and when we should go for. You all must be thinking what if we want to call the controller of child component controller from the parent component. So, in this post we will see how we can do the above things.

aura:method: – Use <aura:method> to define a method as part of a component’s API. This enables you to directly call a method in a component‚Äôs client-side controller instead of firing and handling a component event.

The <aura:method> tag has these system pre defined attributes that we can use

Name: – The method name. Use the method name to call the method in JavaScript code.

Action: – The client-side controller action to execute

Access: – he access control for the method. Valid values are: public and global

Description: – The description of method.

Declaring Parameters: – We can also use parameters to send the values from parent to child using the attributes.

Below is sample of child Component


<aura:method name=”sampleMethod” action=”{!c.doAction}”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† description=”Sample method with parameters”>
¬†¬†¬†¬†¬†¬† <aura:attribute name=”param1″ type=”String” default=”parameter 1″/>
¬†¬†¬†¬†¬†¬† <aura:attribute name=”param2″ type=”String” />


Define the action that needs to be executed when “sampleMethod” gets called from the parent component. Create a method into Controller of Child Component. Child Component Controller sample code.


doAction : function(cmp, event) {
var params = event.getParam(‘arguments’);
if (params) {
var param1 = params.param1;
// add your code here


Get the value into the child controller: – Retrieve the arguments using event.getParam(‘arguments’). It returns an object if there are arguments or an empty array if there are no arguments. For example if you are passing 2 parameters then you can get like below

Step1: – Get the array of all the arguments

var params = event.getParam(‘arguments’);

Step2: – Now, get the value of the attribute using the name of the attribute.

var param1 = params.param1;

var param2 = params.param2;

In Final Step Call the method from the Parent Code: –

Step1: – Call the child component inside the parent component using the syntax like below and use aura:id for the child component which will let you find the child component and then you can call the controller method.

<c:childComponent aura:id=’childCmp’ /> – Use this Syntax if no namespace is defined by you.

<yourNameSpace:childComponent aura:id=’childCmp’ /> Use this Syntax if you have your own¬†¬†¬†¬†¬†¬† namespace is defined by you.

Step2: – Create a button OR any event in which you want to execute the child controller method.

<lightning:button variant=”brand” label=”Submit” onclick=”{! c.handleClick }” />

Step3 : – Call the child controller method from the parent controller method.


handleClick : function(component, event, helper){

// Find the child component using the aura:id that we have given while creating the parent component and store the same into a variable.

var childCmp = component.find(‘childCmp’);

// Call the Child Controller method using childCmp variable dot method name defined into the child component

childCmp.sampleMethod(‘Sample Value for Param 1’, ‘Sample Value For Param 2’); // Pass the parameters here



Example: – For an example we will take a very simple scenario for creating quick contact for the selected account doing this we will reduce the work of going to account detail page and then create a contact from there. You can get the complete code from Here.

Component will look like below.

Aura Method.gif


Happy Coding ūüôā

If you have any questions let me know in comments Section.

Resource: –

Salesforce Document