Another Salesforce blog!!!

Salesforce, Apex


using string literals

Literal strings must be enclosed in single quotation marks. double quotation marks are reserved for enclosing attribute values, and must be escaped in strings. Use the “\” character to escape strings.

understanding how the component event fired

Lets create the component event first and called it “StudentSelectedEvent”: <aura:event type=”COMPONENT” description=”Selected Student” > <aura:attribute name=”contactId” type=”Id” ></aura:attribute> </aura:event> The name attribute in must match the name attribute in the tag in the component that fires the event. in the above component event the type of event is “COMPONENT” and we have one attribute […]


–Calling base component WITH passing params <aura:component controller=”XXXXX” extends=”c:Base” > <lightning:select label=”select instructor” variant=”label-hidden” name=”instructor” value=”{!v.selectedInstructorId}” onchange=”{!c.onInstructorChange}” > <option value=””> select instructor </option> <aura:iteration items=”{!v.instructors}” var=”i”> <option value=”{!i.Id}”> {!i.Name} </option> </aura:iteration> </lightning:select> onInstructorChange : function(component, event, helper) { component.set(‘v.selectedDeliveryId’,”); var selInstructorId = component.get(‘v.selectedInstructorId’); if(component.get(‘v.selectedInstructorId’) != ” && component.get(‘v.selectedInstructorId’) != null) { helper.callServer( component,”c.getDeliveriesByInstructor”, function(response) { […]

Calling generic base component by extends

–Calling base component without passing any params <aura:component controller=”XXXXX” extends=”c:Base” > <aura:handler name=”init” value=”{!this}” action=”{!c.doInit}”/> ({ doInit : function(component, event, helper) { helper.callServer( component, “c.getCertifications”, function(response) { component.set(‘v.certifications’, response); } ); } })

lightning abstract base super component

–Base Component: <aura:component abstract=”true” > {!v.body} </aura:component> –Base Component Helper: ({ callServer : function(component,method,callback,params) { var action = component.get(method); if (params) { action.setParams(params); } action.setCallback(this,function(response) { var state = response.getState(); if (state === “SUCCESS”) { // pass returned value to callback function,response.getReturnValue()); } else if (state === “ERROR”) { // generic error handler var […]

Lightning Data Service Basics

Link Lightning Data Service Basics Let’s create component named “accDisplay” <aura:component description=”accDisplay” implements=”flexipage:availableForRecordHome,force:hasRecordId”> <aura:attribute name=”recordId” type=”String” /> <aura:attribute name=”record” type=”Object” /> <aura:attribute name=”accountRecord” type=”Object” /> <force:recordData recordId=”{!v.recordId}” targetRecord=”{!v.record}” targetFields=”{!v.accountRecord}” fields=”Id, Name” mode=”VIEW”/> <lightning:card iconName=”standard:account” title=”{!v.accountRecord.Name}” > <label class=”slds-form-element__label”>Name: </label> <ui:outputText value=”{!v.accountRecord.Name}”/> <br/> <label class=”slds-form-element__label”>Industry: </label> <lightning:formattedText title=”Industry” value=”{!v.accountRecord.Industry}”/> <br/> <label class=”slds-form-element__label”>Description: </label> <lightning:formattedText title=”Description” value=”{!v.accountRecord.Description}”/> […]

Lightning Components Basics

LINK HERE: Lightning Components Basics Let’s create component named “Camping” <aura:component controller=”CampingListController”> <!– –> <!– the Apex server side controller –> <aura:attribute name=”items” type=”Camping_Item__c[]”/> <c:campingHeader /> <c:campingList items=”{!v.items}”/> </aura:component> Let’s create component named “campingList” <aura:component controller=”CampingListController”> <aura:handler name=”init” action=”{!c.doInit}” value=”{!this}”/> <aura:handler name=”addItem” event=”c:addItemEvent” action=”{!c.handleAddItem}”/> <!– use same type of event –> <aura:handler name=”updateItem” event=”c:addItemEvent” […]