Custom Sorting in Salesforce Lightning Component

//Apex Class :- “CustomSortingController”public class CustomSortingController {@AuraEnabledpublic static list < contact > getContact(string sortField, boolean AscDsc) {system.debug(‘sortField–>’ + sortField);system.debug(‘AscDsc–>’ + AscDsc);String soql = ”;soql = ‘ select firstName, lastName, Email […]

create dependent picklist between Account and Contact in salesforce

//Apex Class:- “customPickListController” public class customPickListController {    public List < SelectOption > lstAccntName {get;set;}    public List < SelectOption > lstcnctoption { get;set;}    public string accid { get;set;}    public customPickListController() {        bindCustomPicklist();        lstcnctoption = new List < SelectOption > ();        lstcnctoption.add(new SelectOption(‘0’, ‘No Data’));    }    public PageReference bindCustomPicklist() {        lstAccntName = new List < SelectOption > ();        List < Account > lstacc = [select id, Name from Account];        system.debug(‘<<<<lstacc>>>>’ + lstacc);        if (lstacc.size() > 0) {            lstAccntName.add(new SelectOption(‘0’, ‘–Select–‘));            for (Account acc: lstacc) {                system.debug(‘<<<<>>>>’ +;                system.debug(‘<<<<acc.Name>>>>’ + acc.Name);                lstAccntName.add(new SelectOption(, acc.Name));            }        }        system.debug(‘<<<<lstAccntName>>>>’ + lstAccntName);        return null;    }    public PageReference getContactDetails() {        system.debug(‘<<<<accid>>>>’ + accid);        List < contact > lstcnct = [select id, lastname from contact where accountid =: accid];        system.debug(‘<<<<lstcnct>>>>’ + lstcnct);        lstcnctoption = new List < SelectOption > ();        if (lstcnct.size() > 0) {            lstcnctoption.clear();            for (contact cnct: lstcnct) {                system.debug(‘<<<<>>>>’ +;                system.debug(‘<<<<cnct.lastname>>>>’ + cnct.lastname);                lstcnctoption.add(new SelectOption(, cnct.lastname));            }        } else {            lstcnctoption.clear();            lstcnctoption.add(new SelectOption(‘0’, ‘No Data’));        }        system.debug(‘<<<<lstcnctoption>>>>’ + lstcnctoption);        return null;    }} //VisualForce Page:- “CustomPicklistExample” <apex:page id=”pageid” controller=”customPickListController” > <apex:form id=”frmid”> <script> function selectAccount() { debugger; var el = document.getElementById(“pageid:frmid:j_id3:j_id4:AccntId00:picklistvalid”); var value = el.options[el.selectedIndex].value; var text = el.options[el.selectedIndex].text; […]

Custompagination in Lightning Component-Salesforce

//Apex Class:- ContactAuraController// What is Offset in SOQL ?// Using OFFSET in SOQLpublic class ContactAuraController {@AuraEnabledpublic static ContactWrapperClass getContactData(Decimal pageNumber, Decimal pageSize) {system.debug(‘Prev pageNumber>>>>>’+pageNumber);system.debug(‘Prev pageSize>>>>>’+pageSize);Integer pSize = (Integer)pageSize;Integer pNumber = […]

Using Loading Spinner with Modal Popup and showing Records In Lightning Component – Salesforce

//Apex Class:- “AccountDetailsClass”public class AccountDetailsClass {@AuraEnabled public static wrapperClassAccnt getAccounts(){List<Account> accList= [SELECT Id,Name,Phone,Industry from Account order by createdDate desc Limit 10]; wrapperClassAccnt accntobj=new wrapperClassAccnt();accntobj.lstaccnt=accList;return accntobj;}@AuraEnabled public static string getAccountsDetails(string accid){system.debug(‘<<<accid>>>’+accid);List<Account> […]

Create Modal Popup Box In Lightning Component – Salesforce

<!–ModalPopupComponent–><aura:component><aura:attribute name=”openModal” type=”boolean” default=”false”/><div class=”slds-m-around–xx-large”><button class=”slds-button slds-button–brand” onclick=”{!c.handleOpenModal}”>Open Modal</button> <aura:if isTrue=”{!v.openModal}”><!–Modal Box Start–><div role=”dialog” class=”slds-modal slds-fade-in-open “><div class=”slds-modal__container”><div class=”slds-modal__header”> <h1 class=”slds-text-heading–medium”>Bvenkat Jeewesh</h1></div> <!–Modal Box Header–><div class=”slds-modal__content slds-p-around–medium”><center> <p><b>Welcome to Bvenkat […]

Delete selected record with confirmation message in Lightning Component

//Apex Controller:- accListClassDetailspublic class accListClassDetails{@AuraEnabled public static wrapperClassAccnt getAccounts(){List<Account> accList= [SELECT Id,Name,Phone,Industry from Account order by createdDate desc Limit 10]; wrapperClassAccnt accntobj=new wrapperClassAccnt();accntobj.lstaccnt=accList;return accntobj;}@AuraEnabled public static string delSelectRecrds(List<string> lstselectId){string msg=”; […]

Check/Uncheck All Checkboxes in Lightning Component

//Apex Controller:- accListClasspublic class accListClass{@AuraEnabled public static wrapperClassAccnt getAccounts(){List<Account> accList= [SELECT Id,Name,Phone,Industry from Account Limit 10]; wrapperClassAccnt accntobj=new wrapperClassAccnt();accntobj.lstaccnt=accList;return accntobj;}// wrapper or Inner class with @AuraEnabled {get;set;} properties* public class […]

Lightning Datatable with hyperlink example salesforce

Lightning:Datatable component displays tabular format where each column can be displayed based on the data type. Lightning:Datatable also supports inline editing. Lightning:Datatable is not supported on mobile devices. Datatable populated […]

How to Use Wrapper Class In Lightning Component.

Apex Class:- wrapperContactController public class wrapperContactController { @AuraEnabled public static wrapperClassContact initMethod() { // create a wrapper class object and set the wrapper class @AuraEnabled properties and return it to […]

Passing data from a Lightning input Text to Apex Controller and Save Records

//Apex Class :- contactcontroller  public class contactcontroller { @AuraEnabled public static string save(string cnctDetails) { system.debug(‘cnctDetails—-‘+cnctDetails); ContactWC cnctObj = (ContactWC)JSON.deserialize(cnctDetails,ContactWC.class); contact ct=new contact(); ct.LastName=cnctObj.LastName; ct.Email=cnctObj.Email; ct.Phone=cnctObj.Phone; insert ct; return; […]

How to bind dynamically Records in Picklist Lightning Component

Here,I am fetching Records from “Account” object, “Industry” field values and populating Picklist on lightning component using “ui:inputSelect”. Apex Class: dynamicPicklistController  public class dynamicPicklistController { @AuraEnabled public static List < […]

How to create picklist in Lightning Component in Salesforce?

Lightning Component:- PicklistLightningComp <aura:component> <ui:inputSelect aura:Id=”picklistId” multiple=”false” label=”Select Details”> <ui:inputSelectOption label=”-Select–” text=”Select” value=”false”/> <ui:inputSelectOption label=”A” text=”A” value=”true”/> <ui:inputSelectOption label=”B” text=”B”/> <ui:inputSelectOption label=”C” text=”C” /> <ui:inputSelectOption label=”D” text=”D”/> </ui:inputSelect><br/><br/> <ui:button label=”Find […]

Object Relationship in Salesforce:-

Relationship is a bi-directional association between two objects. Relationship create links between one object to another object. There are following Types of Relationship:- (a) Master-Detail. (b) Lookup. (c) Many-to-Many. (a) […]