Salesforce Lightning Custom Components for Menus

Sample Code:

<aura:component implements="force:appHostable" >
    
    <div class="slds-box slds-theme_default">
        <lightning:buttonMenu alternativeText="Toggle menu">
            <lightning:menuItem label="Menu Item 1" value="menuitem1"/>
            <lightning:menuItem label="Menu Item 2" value="menuitem2"/>
            <lightning:menuItem label="Menu Item 3" value="menuitem3"/>
        </lightning:buttonMenu>
        <br/><br/>
        <div style="width:90px;">
            <ui:menu >
                <ui:menuTriggerLink aura:id="trigger" label="Select Menu"/>
                <ui:menuList class="actionMenu" aura:id="actionMenu">
                    <ui:actionMenuItem aura:id="item1" label="Menu1"/>
                    <ui:actionMenuItem aura:id="item2" label="Menu2"/>
                    <ui:actionMenuItem aura:id="item3" label="Menu3"/>
                    <ui:actionMenuItem aura:id="item4" label="Menu4"/>
                </ui:menuList>
            </ui:menu>
        </div>
    </div>
    
</aura:component>

Output:

Button Menu:



Menu:



How to find substring between characters in Salesforce using apex?

Sample Code:

String str = 'a"abc"';

system.debug('String between quotes is ' + str.subStringBetween('"', '"'));

Output:


Validation rule for blank space or white space in Salesforce

\\s is used in Validation rule for blank space or white space in Salesforce.

Sample Validation Rule:

AND( 
NOT(ISBLANK(Test__c)), 
AND(NOT(REGEX(Test__c, '\\d{14}')), 
NOT(REGEX(Test__c, '\\d{3}\\s{1}\\d{3}\\s{1}\\d{3}\\s{1}\\d{5}')) 

)

This will support only the below

12345678912345
or
123 456 789 12345

How to show Custom Metadatatype records in Lightning Component?

Apex class:

public class USStateCodeController {

    @AuraEnabled
    public static List < US_State_Codes__mdt > fetchUSStateCodes() {
        return [ SELECT Label, State_Code__c FROM US_State_Codes__mdt ORDER BY Label ];
    }
}

USStateCode.cmp:

<aura:component implements="force:appHostable" controller="USStateCodeController" >
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchCodes}"/>
    
    <aura:attribute name="codeList" type="US_State_Codes__mdt[]" default=""/>
    <aura:attribute name="mycolumns" type="List"/>
    
    <div class="slds-box slds-theme_default">
        <lightning:datatable data="{! v.codeList }" 
                             columns="{! v.mycolumns }" 
                             keyField="id"
                             hideCheckboxColumn="true"/>
    </div>

</aura:component>

USStateCodeController.js:

({
fetchCodes : function(component, event, helper) {
         component.set('v.mycolumns', [
            {label: 'Label', fieldName: 'Label', type: 'text'},
                {label: 'State Code', fieldName: 'State_Code__c', type: 'text'}
            ]);
        var action = component.get("c.fetchUSStateCodes");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.codeList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})

Output:


How to Load or Update Records in Custom Metadatatype?

1. Go to https://github.com/haripriyamurthy/Deprecated-CustomMetadataLoader.

2. Click Download ZIP.


3. Extract the ZIP file.

4. Create a folder with any name and move the below components alone to the new folder.


5. Create a ZIP file from the folder.

6. Use Workbench to deploy the zip.


Note:
You can use the below options too for deployment.

1. aside.io
2. Force.com IDE with Eclipse
3. Apache ANT tool

7. Choose file and click Next.


8. After successful deployment, go to Custom Metadata Loader tab. Click "Create Remote Site Setting" button.


If you face any issue, create a remote site as below. The URL should be the URL of the tab.


9. Select file, metadata type and click Create/Update custom metadata.


Note:

1. If the file has duplicate Label or Developer Name entries, the last entry becomes the new or updated record.

2. Header must contain the api names of the fields.

Lookup field with option to create new record in Custom Lightning Component

Sample Code:

<aura:component implements="force:appHostable" >

     <aura:attribute name="oppty" 
                    type="Opportunity" 
                    default="{ 'sobjectType': 'Opportunity'}"/>
    
    <div class="slds-box slds-theme_default">
        Account : <force:inputField value="{!v.oppty.AccountId}"/>
    </div>
    

</aura:component>

Output:


lightning:listView Example

Sample Code:

<aura:component implements="force:appHostable" >

    <lightning:listView aura:id="listViewAccounts"
                        objectApiName="Account"
                        listName="AllAccounts"
                        rows="5" 
                        showActionBar="false" 
                        enableInlineEdit="true"
                        showRowLevelActions="false" />
    

</aura:component>

Output:


How to rename the Feed tab or create custom tab in Lightning Experience?

1. Click Edit Page.


2. Click Tab on the left and Add Tab on the right.


3. Click Details and select Custom.


4. Enter any Name and click Done.


5. Drag and drop the components from left to the newly created tab.


force:hasRecordId in Custom Lightning Component development

Add the force:hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on.

If your component implements force:hasRecordId, you don’t need to add a recordId attribute to the component yourself. If you do add it, don’t change the access level or type of the attribute or the component will cause a runtime error.

The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, recordId isn’t set, and your component shouldn’t depend on it.

1. Create the below lightning component.

AccountLightningComponent.cmp:

<aura:component implements="force:hasRecordId,force:lightningQuickAction" access="global" >
Account Id is {!v.recordId}
</aura:component>

2. Create a Quick Action button as below.


3. Add the Quick Action to the page layout.

4. Open any account record and click Account Lightning Component.


Output:


Lightning Component Navigation in Salesforce

Sample Code:

ComponentOne.cmp

<aura:component implements="force:appHostable" >

    <aura:attribute name="Txt" type="String" default=""/>
    <div class="slds-box slds-theme_default">
        This is component 1.<br/><br/>
        <lightning:input type="text" value="{!v.Txt}" label="Enter Text : "/><br/><br/>
    <lightning:button variant="brand" label="Navigate" onclick="{!c.navigateToComTwo}"/>
    </div>
    
</aura:component>

ComponentOneController.js

({
    navigateToComTwo : function(component, event, helper) {
        var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef : "c:ComponentTwo",
            componentAttributes: {    
                Text : component.get("v.Txt")
            }
        });
        evt.fire();
}
})

ComponentTwo.cmp

<aura:component implements="force:appHostable">
    
    <aura:attribute name="Text" type="String" default=""/>
    <div class="slds-box slds-theme_default">
        This is component two.<br/><br/>
        Text is {!v.Text}.<br/><br/>
    <lightning:button variant="brand" label="Back to Component One" onclick="{!c.navigateToComOne}"/>
    </div>
    
</aura:component>

ComponentTwoController.js

({
    navigateToComOne : function(component, event, helper) {
        var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef : "c:ComponentOne",
            componentAttributes: {    
            }
        });
        evt.fire();
}
})

Output:


Once you click Navigate button, it navigates to the ComponentTwo.



How to convert or encode/decode utf to string online

To convert or encode/decode utf to string online, check the below links

https://r12a.github.io/apps/conversion/

http://www.cafewebmaster.com/online_tools/utf8_encode - Select Raw URL Decode

https://www.url-encode-decode.com

List of Integration Patterns in Salesforce

1. Remote Process Invocation—Request and Reply
Salesforce invokes a process on a remote system, waits for completion of that process, and then tracks state based on the response from the remote system.

Example:
A custom Visualforce page or button initiates an Apex SOAP or REST callout in a synchronous manner.

2. Remote Process Invocation—Fire and Forget
Salesforce invokes a process in a remote system but doesn’t wait for completion of the process. Instead, the remote process receives and acknowledges the request and then hands off control back to Salesforce.

Example:
a. Workflow-driven outbound messaging
b. Outbound messaging and callback
c. Custom Visualforce page that initiates an Apex SOAP or HTTP asynchronous callout

3. Batch Data Synchronization
Data stored in Lightning Platform should be created or refreshed to reflect updates from an external system, and when changes from Lightning Platform should be sent to an external system. Updates in either direction are done in a batch manner.

Example:
Leverage a third-party ETL tool that allows you to run change data capture against source data.

4. Remote Call-In
Data stored in Lightning Platform is created, retrieved, updated, or deleted by a remote system.

Example:
a. SOAP API
b. REST API
c. BULK API

5. UI Update Based on Data Changes
The Salesforce user interface must be automatically updated as a result of changes to Salesforce data.

Example:
Push Topic

What is the use of Individual object and how to enable it?

Individual object represents a customer’s data privacy and protection preferences. Data privacy records based on the Individual object store customer's privacy preferences and are associated with a lead or a contact.

1. Go to Data Protection and Privacy under Company Settings.


2. Edit Data Protection and Privacy.


3. Save Data Protection and Privacy.


4. Add the Individual field to Lead, Contact, or Person Account page layouts.

What is Concurrent Request Limit in Salesforce?

Once a synchronous Apex request runs longer than 5 seconds, it begins counting against this limit. Each organization is allowed 10 concurrent long-running requests. If the limit is reached, any new synchronous Apex request results in a runtime exception. This behavior occurs until the organization’s requests are below the limit.

Some useful tips:
  1. Convert synchronous processes to asynchronous processes. Batch Apex might be a viable alternative. Limit synchronous Web service callouts.
  2. Use the Streaming API instead of polling.
  3. Tune SOQL and DML operations. Make sure that your queries are selective. Limit the number of records in your list views. Avoid data skew.
  4. Use the Continuation class to make callouts asynchronously to a SOAP or REST Web service from a Visualforce page.

Simple Pagination Example in Lightning Component

Sample Code:

Component:

<aura:component implements="force:appHostable"
                controller="OpportunitySearchController">
    
<aura:attribute name="oppty" 
                    type="Opportunity" 
                    default="{ 'sobjectType': 'Opportunity'}"/>
<aura:attribute name="columns" type="List"/>    
<aura:attribute name="opportunityList" type="Opportunity[]"/>
<aura:attribute name="PaginationList" type="Opportunity[]"/>
<aura:attribute name="startPage" type="Integer" />
<aura:attribute name="endPage" type="Integer"/>
<aura:attribute name="totalRecords" type="Integer"/>
<aura:attribute name="pageSize" type="Integer" default="3"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
<div class="slds-box slds-theme_default">
        <div class="slds-grid slds-grid_vertical">
            <div class="slds-col">
                Close Date<force:inputField value="{!v.oppty.CloseDate}"/>
            </div>
            <div class="slds-col">
                Amount<force:inputField value="{!v.oppty.Amount}"/>
            </div>  
            <div class="slds-col">
                <lightning:button label="Search" onclick="{!c.searchOppty}"/>
            </div>              
        </div>
    </div>
    
    <aura:if isTrue="true">
        <div class="slds-grid slds-grid_vertical">
            <lightning:datatable data="{!v.PaginationList}"
                                 columns="{!v.columns}" 
                                 keyField="id"
                                 hideCheckboxColumn="true"/>
            <lightning:buttonGroup>
                <lightning:button label="Previous" 
                                  disabled="{!v.startPage == 0}"  
                                  onclick="{!c.previous}" 
                                  variant="brand"
                                  iconName='utility:back'/>
                <lightning:button label="Next" 
                                  disabled="{!v.endPage + 1 >= v.totalRecords}" 
                                  onclick="{!c.next}" 
                                  variant="brand"
                                  iconName='utility:forward'/>
            </lightning:buttonGroup>
        </div>
    </aura:if>
    
</aura:component>

Controller:

({
doInit: function (component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', type: 'text'},
{label: 'Closed Date', fieldName: 'CloseDate', type: 'date'},
{label: 'Stage', fieldName: 'StageName', type: 'text'}
]);
},
searchOppty : function(component) {
var action = component.get('c.searchOpportunities');
        action.setParams({
            clsDate : new Date(component.get("v.oppty.CloseDate")).toJSON(),
            amt : component.get("v.oppty.Amount")
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if ( state === 'SUCCESS' && component.isValid() ) {
                var pageSize = component.get("v.pageSize");
                component.set('v.opportunityList', response.getReturnValue());
                component.set("v.totalRecords", component.get("v.opportunityList").length);
                component.set("v.startPage", 0);                
                component.set("v.endPage", pageSize - 1);
                var PagList = [];
                for ( var i=0; i< pageSize; i++ ) {
                    if ( component.get("v.opportunityList").length> i )
                        PagList.push(response.getReturnValue()[i]);    
                }
                component.set('v.PaginationList', PagList);
            } else {
                alert('ERROR');
            }
        });
        $A.enqueueAction(action);
},
next: function (component, event, helper) {
var sObjectList = component.get("v.opportunityList");
        var end = component.get("v.endPage");
        var start = component.get("v.startPage");
        var pageSize = component.get("v.pageSize");
        var PagList = [];
        var counter = 0;
        for ( var i = end + 1; i < end + pageSize + 1; i++ ) {
            if ( sObjectList.length > i ) {
                PagList.push(sObjectList[i]);
            }
            counter ++ ;
        }
        start = start + counter;
        end = end + counter;
        component.set("v.startPage", start);
        component.set("v.endPage", end);
        component.set('v.PaginationList', PagList);
},
previous: function (component, event, helper) {
var sObjectList = component.get("v.opportunityList");
        var end = component.get("v.endPage");
        var start = component.get("v.startPage");
        var pageSize = component.get("v.pageSize");
        var PagList = [];
        var counter = 0;
        for ( var i= start-pageSize; i < start ; i++ ) {
            if ( i > -1 ) {
                PagList.push(sObjectList[i]);
                counter ++;
            } else {
                start++;
            }
        }
        start = start - counter;
        end = end - counter;
        component.set("v.startPage", start);
        component.set("v.endPage", end);
        component.set('v.PaginationList', PagList);
}
})

Apex Class:

public class OpportunitySearchController {
    
    @auraEnabled
    public static List < Opportunity > searchOpportunities(String clsDate, Double amt) {
        system.debug(clsDate + ' - ' + amt);
        Date closeDate = Date.valueOf(clsDate);
        return [ SELECT Id, Name, CloseDate, StageName FROM Opportunity WHERE CloseDate =: closeDate AND Amount >: amt LIMIT 100 ]; 
    }

}

Output:


Date Picker in Lighting Component

Sample Code:

<aura:component implements="force:appHostable" >
    
    <div class="slds-box slds-theme_default">
    <lightning:input type="date" label="Date"/>
    </div>
    

</aura:component>

Output:


How to refer object's fields in Lighting Component?

<force:inputField> can be usedto refer object's fields in Lighting Component.

Sample Code:

<aura:component implements="force:appHostable">
    
    <aura:attribute name="oppty" 
                    type="Opportunity" 
                    default="{ 'sobjectType': 'Opportunity'}"/>
<div class="slds-box slds-theme_default">
        <div class="slds-grid slds-grid_vertical">
            <div class="slds-col">
                Name<force:inputField value="{!v.oppty.Name}"/>
            </div>
            <div class="slds-col">
                Amount<force:inputField value="{!v.oppty.Amount}"/>
            </div>              
        </div>
    </div>
    
</aura:component>

Output:


Lighting Data Table Sorting Example

AccountList.cmp

<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:attribute name="sortedBy" type="String" default="Name"/>
    <aura:attribute name="sortedDirection" type="String" default="asc"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <lightning:datatable data="{!v.acctList}" 
                         columns="{!v.mycolumns}" 
                         keyField="id"
                         hideCheckboxColumn="true"
                         onsort="{!c.updateColumnSorting}"
                         sortedBy="{!v.sortedBy}"  
                        sortedDirection="{!v.sortedDirection}"/>
    
</aura:component>

AccountListController.js

({
    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'Name', type: 'text', sortable: true},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
            }
        });
        $A.enqueueAction(action);
    },
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        var sortDirection = event.getParam('sortDirection');
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    }
})

AccountListHelper.js:

({
    sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.acctList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.acctList", data);
    },
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x[field])} :
            function(x) {return x[field]};
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }
})

AccountListController apex class:

public class AccountListController {

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

Output:


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

https://success.salesforce.com/ideaView?id=08730000000l1yFAAQ

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:

Component:

<aura:component implements="force:appHostable" >
    
    <lightning:fileUpload label="Attach receipt"
        name="fileUploader" 
        multiple="true" 
        accept=".pdf, .png"
        recordId="0016A00000MneVlQAJ" 
        onuploadfinished="{!c.handleUploadFinished}" />
    
</aura:component>

Controller:

({
    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

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_fileUpload.htm

Output:




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" />
    </lightning:recordEditForm>
    
</aura:component>

Output:


How to write Page Reference for Save in Lightning Component?

Use e.force:createRecord.

Sample Code:

Component:

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

Controller:

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

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

SamplePage

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

SamplePageController

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);
        pg.setRedirect(true);
        return pg;
    }

}

NextPage

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

NextPageController

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:


Output:



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?

Yes.

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 ready.
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 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.

16. List of Integration Patterns in Salesforce

http://www.infallibletechie.com/2018/03/list-of-integration-patterns-in.html

Bad file:Element {http://soap.sforce.com/2006/04/metadata} invalid at this location

Bad file:Element {http://soap.sforce.com/2006/04/metadata} 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}"/>
    </flow:interview>
</apex:page>

lightning:datatable in Salesforce Lightning Component

AccountList.cmp:

<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 }" 
                         keyField="id"
                         hideCheckboxColumn="true"/>
    
</aura:component>

AccountListController.js

({
    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.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})

AccountListController Apex Class:

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

Output:


Cheers!!!

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.

QuickCreateAccount.cmp:

<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"
                      layoutType="FULL"
                      targetRecord="{!v.newAccount}"
                      targetFields="{!v.simpleNewAccount}"
                      fields="Name,Industry,Type"
                      targetError="{!v.newAccountError}"
                      mode="New"/>
    <div class="slds-page-header" role="banner">
        <p class="slds-text-heading_label">Create Account</p>
    </div>

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

    <!-- 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"/>
   </div>

</aura:component>

QuickCreateAccountController.js:

({
    doInit: function(component, event, helper) {
        // Prepare a new record from template
        component.find("accountRecordCreator").getNewRecord(
            "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);
                    return;
                }
                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.


Output: