How to navigate to related list record in Lighting Experience?

The related list shows record with Name as Hyper Links.

Check the below example of Contact record's Case Related List.

Marketing Cloud Developer Edition for Individual Learner

Currently, Salesforce is not providing Developer Edition for Marketing Cloud.

Check the below link and vote for this

Once the above idea is delivered, you will get developer edition for Marketing Cloud products from Salesforce.

Keep checking the link!!!

lightning:fileUpload component example

Sample Code:


<aura:component implements="force:appHostable" >
    <lightning:fileUpload label="Attach receipt"
        accept=".pdf, .png"
        onuploadfinished="{!c.handleUploadFinished}" />


    handleUploadFinished: function (cmp, event) {
        var uploadedFiles = event.getParam("files");
        alert("Files uploaded");

event.getParam("files") returns the list of files uploaded. Here recordId attribute is hard coded.

For more information, check the below link


lightning:recordEditForm with lookup field

Lightning Component Code:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" >
    <lightning:recordEditForm recordId="0031I000008YCvoQAG" objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:inputField fieldName="AccountId" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />


How to write Page Reference for Save in Lightning Component?

Use e.force:createRecord.

Sample Code:


<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" >
    <lightning:button label="Create Account" onclick="{!c.createRecord}"/>


    createRecord : function (component) {
        var createRecordEvent = $A.get("e.force:createRecord");
            "entityApiName": "Account"

Once the create record event is fired, it will take to you the newly created account record.

Mass Transfer Records in Salesforce Lightning

1. Go to Data --> Mass Transfer Records.

2. Select the object for transferring owner.

Passing Values to Visualforce page from Lightning Experience


<apex:page standardController="Account" extensions="SamplePageController" action="{!redirectToVF}">


public class SamplePageController {

    public Account acct {get;set;}

    public SamplePageController(ApexPages.StandardController controller) {
        acct = [ SELECT Id, Name FROM Account WHERE Id =: controller.getId() ];
    public PageReference redirectToVF() {
        PageReference pg = new PageReference('/apex/NextPage?aid=' + acct.Id + '&name=' + acct.Name);
        return pg;



<apex:page controller="NextPageController">
Account Id is {!accountId}<br/>
Account Name is {!accountName}


public class NextPageController {

    public String accountId {get;set;}
    public String accountName {get;set;}
    public NextPageController() {
        accountId = ApexPages.currentPage().getParameters().get('aid');
        system.debug('Account Id is ' + accountId);
        accountName = ApexPages.currentPage().getParameters().get('name');

Custom Visualforce button:


Salesforce Interview Questions with Answers Part 50

1. How to use Lightning Components with the Salesforce1 Mobile App?

Create a custom Lightning tab that include Lightning component.

2. Can child lightning component inherit styles from parent lightning component?


3. What is the use of the aura:method tag in Lightning?

< 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. This simplifies the code needed for a parent component to call a method on a child component that it contains.

4. What is Aura?

Aura is the open source technology that powers Lightning Components.

5. Do we need a namespace to develop Lightning Components?

No. Lightning Components used to require a namespace, but that is no longer a requirement.

6. What are the advantages of lightning?

1. Responsive UI
2. Cross Browser Compatability
3. Reusable components
4. Lightning allows us to build software quickly and reliably test it.
5. Readily available in Mobile.

7. What is Lightning Experience?

Lightning Experience is the name for the all new Salesforce desktop app.

8. What is the basic difference between Application Event and Component Event

The major difference between application and component event is that component event is used in child to parent components and application event can be used through out the application.

9. How can we call child component controller method from the parent component controller method?

Yes, we can call using aura methods.

10. What is the use of Document and Renderer in lightning component?

Document – A description, sample code, and one or multiple references to example components
Renderer - Client-side renderer to override default rendering for a component.

11. Disadvantages with Lighting Experience

1. All AppExchange products are not lighting read.
2. It takes more time to migrate complex customized classic Salesforce app to Lightning ready.

12. How to ensure FLS while working with Lightning Component?

Lightning Data Services already ensures Field Level Security and we can also use into the Apex using isAccessible, isCreateable, isDeleteable, isCreateable and etc methods of Schema class.

13. How to add Lightning Component in Visualforce page?

Lightning component can be added to visualforce page using ltng:outApp.

14. How to extend lightning component? 

Lighting component can be extended using extensible=”true” attribute in aura:component.

15. What is the use of svg in aura bundle?

Custom icon resource for components used in the Lightning App Builder or Community Builder.

Bad file:Element {} invalid at this location

Bad file:Element {} invalid at this location error occurs due to the following

1. Formatting in package.xml is incorrect.

2. Formatting in destrcutivechanges.xml is incorrect.

Check whether some white space is present in the file. Double check the name attribute in all types in both package.xml and destructivechanges.xml.

How to Embed Flows in Visualforce Page?

To add a flow to a Visualforce page, embed it using the <flow:interview> component.

Sample Code:

<apex:page standardController="Case" tabStyle="Case" >
    <flow:interview name="CaseDefaultFlow">
        <apex:param name="vaCaseNumber" value="{!Case.CaseNumber}"/>

lightning:datatable in Salesforce Lightning Component


<aura:component controller="AccountListController"
                implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" >
    <aura:attribute type="Account[]" name="acctList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    <lightning:datatable data="{! v.acctList }" 
                         columns="{! v.mycolumns }" 


    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'Name', type: 'text'},
                {label: 'Industry', fieldName: 'Industry', type: 'text'},
                {label: 'Type', fieldName: 'Type', type: 'Text'}
        var action = component.get("c.fetchAccts");
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());

AccountListController Apex Class:

public class AccountListController {
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type FROM Account LIMIT 10 ];



Creating a Record using Lightning Data Service

To create a record using Lightning Data Service, declare force:recordData without assigning a recordId. Next, load a record template by calling the getNewRecord function on force:recordData. Finally, apply values to the new record, and save the record by calling the saveRecord function on force:recordData.


<aura:component implements="force:lightningQuickAction">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="newAccount" type="Object"/>
    <aura:attribute name="newAccountError" type="String"/>
    <aura:attribute name="simpleNewAccount" type="Object"/>

<force:recordData aura:id="accountRecordCreator"
    <div class="slds-page-header" role="banner">
        <p class="slds-text-heading_label">Create Account</p>

    <!-- Display Lightning Data Service errors -->
    <aura:if isTrue="{!not(empty(v.newAccountError))}">
        <div class="recordError">
            <ui:message title="Error" severity="error" closable="true">

    <!-- Display the new Account form -->
    <div class="slds-form_stacked">
        <lightning:input name="name" label="Name"
                         value="{!v.simpleNewAccount.Name}" required="true"/>
        <lightning:input name="industry" label="Industry"
                      value="{!v.simpleNewAccount.Industry}" required="true"/>
        <lightning:input name="type" label="Type"
                      value="{!v.simpleNewAccount.Type}" />
        <lightning:button label="Save Account" onclick="{!c.handleSaveAccount}"
                   variant="brand" class="slds-m-top_medium"/>



    doInit: function(component, event, helper) {
        // Prepare a new record from template
            "Account", // sObject type 
            null,      // recordTypeId
            false,     // skip cache?
            $A.getCallback(function() {
                var rec = component.get("v.newAccount");
                var error = component.get("v.newAccountError");
                if(error || (rec === null)) {
                    console.log("Error initializing record template: " + error);
                console.log("Record template initialized: " + rec.sobjectType);

    handleSaveAccount: function(component, event, helper) {
        component.find("accountRecordCreator").saveRecord(function(saveResult) {
            if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                // handle the successful create
            } else if (saveResult.state === "INCOMPLETE") {
                // handle the incomplete state
                console.log("User is offline, device doesn't support drafts.");
            } else if (saveResult.state === "ERROR") {
                // handle the error state
                console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
            } else {
                console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));

Quick Action Button in Account:

1. Add the Quick Action to the Account Page Layout.

2. Open an Account record.

3. Click Quick Create Account.


How to get URL parameter in Salesforce community page lightning component?


Controller Code:

var idParam = helper.getJsonFromUrl().id;//will get abc as id
var strParam = helper.getJsonFromUrl().str;//will get test as str

Helper Code:

getJsonFromUrl : function () {
        var query =;
        var result = {};
        query.split("&").forEach(function(part) {
            var item = part.split("=");
            result[item[0]] = decodeURIComponent(item[1]);
        return result;