SlideShare a Scribd company logo
1
About Myself!
I am Sunil Kumar
7x Salesforce Certified | Developer | Blogger
Twitter : @sunil02kumar
Blog: https://sunil02kumar.blogspot.in
Facebook Page : SalesforceArticles
I am here for Hands on training session on
Salesforce events & LDS. I think it is the best
way to interact & learn.
”
Practice is the hardest part of
learning, and training is the essence
of transformation.
2
Agenda
▹ Setting up Salesforce environmement for Hands on Training.
▹ Lightning Data Services Overview
▹ Creating lightning component for editing and viewing account records
using Lightning Data Services.
▹ Q&A
3
Setting up Salesforce environmement for
Hands on Training.
▹ Sign up for Developer edition if you don’t have by referring below URL:
https://developer.salesforce.com/gettingstarted
▹ Enable My Domain in your org (Navigate to Set Up-My Domain).
▹ After registering My Domain, deploy it for all users.
4
Upload Static Resource
▹ Download zip file from below URL:
https://goo.gl/U8nfnq
▹ Click on Setup > Static Resouce > New
▹ Specify name as “LightningEventsResources” and browse zip file.
▹ Specify “Public “ for Cache Control field and click on Save.
▹ You can refer below blog to follow steps for hands on training.
https://goo.gl/DUTQfG
▹ GitHub Repository URL for complete code for Hands on Training
https://goo.gl/yoM7nE
5
Lightning Data Services6
Component
(<force:recorddata />
Component
(<force:recorddata />
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
mode="EDIT or VIEW"
layout="FULL or COMPACT"
targetRecord="{!v.recordInfo}"
targetFields="{!v.fieldsInfo}"
fields="Name,Owner.Name,AnnualRevenue,AccountNumber"
targetError="{!v.recordError}"
recordUpdated="{!c.handleRecordChanges}" />
Create a “LDSAccountListViewApp” Lightning Application
▹ In the Developer Console, choose File > New > Lightning Application.
▹ Specify “LDSAccountListViewApp” as the app name and click submit.
▹ Specify below code in lightning app.
▹ Save the file.
▹ Click preview.
7
Place your screenshot here
<aura:application extends="force:slds">
<div class="slds-text-heading_large slds-text-align_center">
Lightning Data Service Demo App
</div>
</aura:application>
Create a LDSAccountEdit lightning Component8
▹ In the Developer Console, choose File > New > Lightning Component.
▹ Specify “LDSAccountEdit” as the component name and click submit. Paste below code and Save the file.
<aura:component >
<aura:attribute name="recordId" type="String" required="true"/>
<aura:attribute name="recordInfo" type="Object"/>
<aura:attribute name="fieldsInfo" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<aura:attribute name="currView" type="String" />
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
mode="EDIT"
targetRecord="{!v.recordInfo}"
targetFields="{!v.fieldsInfo}"
fields="Name,Owner.Name,AnnualRevenue,AccountNumber"
targetError="{!v.recordError}"
recordUpdated="{!c.handleRecordChanges}" />
<div class="maincontainer">
</div>
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
<ui:message title="Error" severity="error" closable="true"> {!v.recordError}
</ui:message>
</div>
</aura:if>
</aura:component>
<lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" />
Create a LDSAccountEdit lightning Component9
▹ Click CONTROLLER in the right side bar of the code editor and replace code with below code and save the file..
({
handleRecordChanges: function(component, event, helper) {
var eventParams = event.getParams();
if(eventParams.changeType === "LOADED") {
// record is loaded
var fieldsDetails= component.get("v.fieldsInfo");
console.log("fieldsInfo is loaded successfully. TargetField"+
JSON.stringify(fieldsDetails));
var recordDetails= component.get("v.recordInfo");
console.log("recordInfo -Target Record"+ JSON.stringify(recordDetails));
console.log('Record loaded successfully');
}
}
})
Lets see what we have done!!!
▹ Update the “LDSAccountListViewApp” code with below code.
▹ Save the file.
▹ Click preview.
10
Place your screenshot here
<aura:application extends="force:slds">
<div class="slds-text-heading_large slds-text-align_center">
Lightning Data Service Demo App
</div>
<c:LDSAccountEdit recordId=“0017F000004R9C3QAK”/>
</aura:application>
Create a LDSAccountEdit lightning Component11
▹ In order to display more account fields, replace the code inside div with class “maincontainer” with below code.
<div class="maincontainer">
<div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1">
<div class="slds-form-element__control" >
<lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" />
</div>
</div>
<div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1">
<div class="slds-form-element__control" >
<lightning:input type="number" label="Annual Revenue" name="atype" value="{!v.fieldsInfo.AnnualRevenue}" formatter="currency"/>
</div>
</div>
<div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1">
<div class="slds-form-element__control" >
<lightning:input label="Account Number" name="accnum" value="{!v.fieldsInfo.AccountNumber}" />
</div>
</div>
<div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1">
<div class="slds-form-element__control" >
<lightning:button variant="brand" label="Save" onclick="{!c.saveRecordHandler}"/>
<lightning:button variant="brand" label="Back" />
</div>
</div>
</div>
Create a LDSAccountEdit lightning Component12
▹ Click CONTROLLER in the right side bar of the code editor and add saveRecordHandler function and save the file..
saveRecordHandler: function(component, event, helper) {
component.find("recordLoader").saveRecord($A.getCallback(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
console.log('Record updated successfully');
}else if (saveResult.state === "ERROR") {
console.log('Problem error: ' + JSON.stringify(saveResult.error));
} else {
console.log('Unknown problem, state: ' + saveResult.state + ', error: ' +
JSON.stringify(saveResult.error));
}
}));
}
Lets see what we have done!!!
▹ Update the “LDSAccountListViewApp” code with below code.
▹ Save the file.
▹ Click preview.
13
Place your screenshot here
<aura:application extends="force:slds">
<div class="slds-text-heading_large slds-text-align_center">
Lightning Data Service Demo App
</div>
<c:LDSAccountEdit recordId=“0017F000004R9C3QAK”/>
</aura:application>
Create a LDSAccountView lightning Component14
▹ In the Developer Console, choose File > New > Lightning Component.
▹ Specify “LDSAccountView” as the component name and click submit.
▹ Copy the code from “LDSAccountEdit” component and paste it here.
▹ Add a attribute disabled=“true” in all lightning:input tag
▹ Remove “handleRecordChanges” attribute from <force:recorddata> tag.
▹ Remove Lightning:button with label as “Save”.
<lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" dsabled="true"/>
Lets see what we have done!!!
▹ Update the “LDSAccountListViewApp” code with below code.
▹ Save the file.
▹ Click preview.
15
Place your screenshot here
<aura:application extends="force:slds">
<div class="slds-text-heading_large slds-text-align_center">
Lightning Data Service Demo App
</div>
<c:LDSAccountView recordId=“0017F000004R9C3QAK”/>
</aura:application>
Create a Apex class to fetch Account records16
▹ Create Apex Class “LDSAccountListViewController” to fetch latest 10 Account records from your org.
public with Sharing class LDSAccountListViewController {
@AuraEnabled public static List<Account> findAccounts(){
List<Account> accList = new List<Account>();
accList=[select id, name,owner.name,type,AccountNumber,AnnualRevenue,Phone from
Account order by lastModifiedDate DESC Limit 10];
return accList;
}
}
Create a LDSAccountListView lightning Component17
▹ In the Developer Console, choose File > New > Lightning Component.
▹ Specify “LDSAccountListView” as the component name and click submit.
<aura:component controller="LDSAccountListViewController" >
<aura:attribute name="accList" type="List" />
<aura:attribute name="menu" type="List" default="View,Edit"/>
<aura:attribute name="currentView" type="String" default="ListView"/>
<aura:attribute name="selectedRecord" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!--Section for Account List View starts-->
<aura:if isTrue="{!v.currentView =='ListView'}">
<div class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<lightning:Icon iconName="standard:account" size="large" variant="inverse" />
</div>
<div class="slds-media__body">
<h2> <span class="slds-text-heading_small">Accounts({!v.accList.length})</span> </h2>
</div>
</header>
<div class="slds-no-flex"> <lightning:button variant="brand" label="New Account" /> </div>
</div>
<div class="slds-card__body slds-card__body_inner">
<aura:if isTrue="{!v.accList.length > 0}"> <!--display all accounts--> </aura:if>
</div>
<footer class="slds-card__footer">@sunil02kumar</footer> </div>
</aura:if>
<!--Section for Account List View ends-->
</aura:component>
Create a LDSAccountListView lightning Component18
▹ Click CONTROLLER in the right side bar of the code editor and add doInit function and save the file..
({
doInit : function(component, event, helper){
var action = component.get("c.findAccounts");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var apexResponse = response.getReturnValue();
//console.log('***apexResponse:'+ JSON.stringify(apexResponse));
component.set("v.accList", apexResponse);
console.log('********Accounts list view loaded successfully');
}else if(state === "ERROR"){
alert('Problem with connection. Please try again.');
}});
$A.enqueueAction(action);
}
})
Lets see what we have done!!!
▹ Update the “LDSAccountListViewApp” code with below code.
▹ Save the file.
▹ Click preview.
19
Place your screenshot here
<aura:application extends="force:slds">
<div class="slds-text-heading_large slds-text-align_center">
Lightning Data Service Demo App
</div>
<c:LDSAccountListView />
</aura:application>
Update LDSAccountListView lightning Component20
▹ Replace <!--display all accounts--> section with below code and save file.
<table class="slds-table slds-table_fixed-layout slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title--caps">
<th scope="col">Actions</th>
<th scope="col">Name</th>
<th scope="col">Account Number</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.accList}" var="item">
<tr class="slds-hint-parent">
<td scope="row">
<lightning:buttonMenu iconName="utility:threedots" >
<aura:iteration items="{!v.menu}" var="menuItem">
<lightning:menuItem label="{!menuItem}" value="{!item.Id + '---' + menuItem}" onactive="{!c.onSelectMenuItem}"/>
</aura:iteration>
</lightning:buttonMenu>
</td>
<td > {!item.Name}</td>
<td > {!item.AccountNumber}</td>
</tr>
</aura:iteration>
</tbody>
</table>
Update a LDSAccountListView lightning Component21
▹ Click CONTROLLER in the right side bar of the code editor and add onSelectMenuItem function and save the file..
onSelectMenuItem : function(component, event, helper) {
var selectedOption = event.getSource().get('v.value');
var selectedId = selectedOption.split('---')[0];
console.log('*************selectedId:'+selectedId); component.set("v.selectedRecord",selectedId);
console.log('*************selectedOption:'+selectedOption);
if (selectedOption.endsWith("View")) {
component.set("v.currentView","RecordView");
}else if(selectedOption.endsWith("Edit")){
component.set("v.currentView","RecordEdit");
}
}
Update LDSAccountListView lightning Component22
▹ Now we are going to display LDSAccountView and LDSAccountEdit components based selection made by user on
menu item
▹ Add below markup code in LDSAccountListView component after the section for account list views and save file.
<!--Section for Account record View starts-->
<aura:if isTrue="{!v.currentView =='RecordView'}">
<c:LDSAccountView recordId="{!v.selectedRecord}" currView="{!v.currentView}"/>
</aura:if>
<!--Section for Account record View ends-->
<!--Section for Account record edit starts-->
<aura:if isTrue="{!v.currentView =='RecordEdit'}">
<c:LDSAccountEdit recordId="{!v.selectedRecord}" currView="{!v.currentView}" />
</aura:if>
<!--Section for Account record edit ends-->
Update LDSAccountView & LDSAccountView lightning
Component23
▹ In LDSAccountEdit component, add action to lightning:button with label as “Back”.
▹ Click CONTROLLER in the right side bar of the code editor and add goBackToListViewfunction and save the file
▹ Same way in LDSAccountView, update lightning:button with label as “Back” and add “goBackToListView” JavaScript
function to controller.
<lightning:button variant="brand" label="Back" onclick="{!c.goBackToListView}"/>
goBackToListView : function(component,event,helper){
component.set("v.currView","ListView");
}
Lets see what we have done!!!24
Place your screenshot herePlace your screenshot here
25
THANKS!
Any questions?
You can find me at
▹ @sunil02kumar
▹ sunil02kumar@gmail.com
Ad

More Related Content

What's hot (20)

07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
Oum Saokosal
 
11.1 Android with HTML
11.1 Android with HTML11.1 Android with HTML
11.1 Android with HTML
Oum Saokosal
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
Atlassian
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
InnovationM
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using now
Atlassian
 
AtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-ons
Atlassian
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
René Winkelmeyer
 
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
NHN FORWARD
 
[2019] 스몰 스텝: Android 렛츠기릿!
[2019] 스몰 스텝: Android 렛츠기릿![2019] 스몰 스텝: Android 렛츠기릿!
[2019] 스몰 스텝: Android 렛츠기릿!
NHN FORWARD
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App Engine
Alexander Zamkovyi
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
Roger Kitain
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
Alexander Zamkovyi
 
Building i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadinBuilding i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadin
Joonas Lehtinen
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum
 
Upload[1]
Upload[1]Upload[1]
Upload[1]
mirjana stojanova
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
Mindfire Solutions
 
Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
Joonas Lehtinen
 
Angular js
Angular jsAngular js
Angular js
prasaddammalapati
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Atlassian
 
Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
 Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg... Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
Brian Mann
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
Oum Saokosal
 
11.1 Android with HTML
11.1 Android with HTML11.1 Android with HTML
11.1 Android with HTML
Oum Saokosal
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
Atlassian
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
InnovationM
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using now
Atlassian
 
AtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-ons
Atlassian
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
René Winkelmeyer
 
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
[2019] 벅스 5.0 (feat. Kotlin, Jetpack)
NHN FORWARD
 
[2019] 스몰 스텝: Android 렛츠기릿!
[2019] 스몰 스텝: Android 렛츠기릿![2019] 스몰 스텝: Android 렛츠기릿!
[2019] 스몰 스텝: Android 렛츠기릿!
NHN FORWARD
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App Engine
Alexander Zamkovyi
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
Roger Kitain
 
Building i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadinBuilding i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadin
Joonas Lehtinen
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
Mindfire Solutions
 
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012 Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Plugins on OnDemand with Remote Apps - Atlassian Summit 2012
Atlassian
 
Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
 Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg... Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
Little Opinions, Big Possibilities: The Tools and Patterns for Building Larg...
Brian Mann
 

Similar to Salesforce Lightning Data Services- Hands on Training (20)

Mule using Salesforce
Mule using SalesforceMule using Salesforce
Mule using Salesforce
Khasim Cise
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
Khasim Saheb
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
F K
 
How to convert custom plsql to web services-Soap OR Rest
How to convert custom plsql to web services-Soap OR RestHow to convert custom plsql to web services-Soap OR Rest
How to convert custom plsql to web services-Soap OR Rest
shravan kumar chelika
 
VMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with ClarityVMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with Clarity
Jeeyun Lim
 
E2 appspresso hands on lab
E2 appspresso hands on labE2 appspresso hands on lab
E2 appspresso hands on lab
NAVER D2
 
E3 appspresso hands on lab
E3 appspresso hands on labE3 appspresso hands on lab
E3 appspresso hands on lab
NAVER D2
 
Rage Against the Framework
Rage Against the FrameworkRage Against the Framework
Rage Against the Framework
David Ortinau
 
Capture, record, clip, embed and play, search: video from newbie to ninja
Capture, record, clip, embed and play, search: video from newbie to ninjaCapture, record, clip, embed and play, search: video from newbie to ninja
Capture, record, clip, embed and play, search: video from newbie to ninja
Vito Flavio Lorusso
 
How to CASifying PeopleSoft and Integrating CAS and ADFS
How to CASifying PeopleSoft and Integrating CAS and ADFSHow to CASifying PeopleSoft and Integrating CAS and ADFS
How to CASifying PeopleSoft and Integrating CAS and ADFS
John Gasper
 
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
Altinity Ltd
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
Christophe Coenraets
 
Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
Jason Ragsdale
 
Reporting solutions for ADF Applications
Reporting solutions for ADF ApplicationsReporting solutions for ADF Applications
Reporting solutions for ADF Applications
Getting value from IoT, Integration and Data Analytics
 
Detect and fix the azure sql resources which uses tls version less than 1.2
Detect and fix the azure sql resources which uses tls version less than 1.2Detect and fix the azure sql resources which uses tls version less than 1.2
Detect and fix the azure sql resources which uses tls version less than 1.2
Prancer Io
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flex
danielwanja
 
FamilySearch Reference Client
FamilySearch Reference ClientFamilySearch Reference Client
FamilySearch Reference Client
Dallan Quass
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
PyCon Italia
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Meetup bangalore aug31st2019
Meetup bangalore aug31st2019Meetup bangalore aug31st2019
Meetup bangalore aug31st2019
D.Rajesh Kumar
 
Mule using Salesforce
Mule using SalesforceMule using Salesforce
Mule using Salesforce
Khasim Cise
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
F K
 
How to convert custom plsql to web services-Soap OR Rest
How to convert custom plsql to web services-Soap OR RestHow to convert custom plsql to web services-Soap OR Rest
How to convert custom plsql to web services-Soap OR Rest
shravan kumar chelika
 
VMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with ClarityVMWorld 2017 Hackathon training: Getting Started with Clarity
VMWorld 2017 Hackathon training: Getting Started with Clarity
Jeeyun Lim
 
E2 appspresso hands on lab
E2 appspresso hands on labE2 appspresso hands on lab
E2 appspresso hands on lab
NAVER D2
 
E3 appspresso hands on lab
E3 appspresso hands on labE3 appspresso hands on lab
E3 appspresso hands on lab
NAVER D2
 
Rage Against the Framework
Rage Against the FrameworkRage Against the Framework
Rage Against the Framework
David Ortinau
 
Capture, record, clip, embed and play, search: video from newbie to ninja
Capture, record, clip, embed and play, search: video from newbie to ninjaCapture, record, clip, embed and play, search: video from newbie to ninja
Capture, record, clip, embed and play, search: video from newbie to ninja
Vito Flavio Lorusso
 
How to CASifying PeopleSoft and Integrating CAS and ADFS
How to CASifying PeopleSoft and Integrating CAS and ADFSHow to CASifying PeopleSoft and Integrating CAS and ADFS
How to CASifying PeopleSoft and Integrating CAS and ADFS
John Gasper
 
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
Altinity Ltd
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
Christophe Coenraets
 
Detect and fix the azure sql resources which uses tls version less than 1.2
Detect and fix the azure sql resources which uses tls version less than 1.2Detect and fix the azure sql resources which uses tls version less than 1.2
Detect and fix the azure sql resources which uses tls version less than 1.2
Prancer Io
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flex
danielwanja
 
FamilySearch Reference Client
FamilySearch Reference ClientFamilySearch Reference Client
FamilySearch Reference Client
Dallan Quass
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
PyCon Italia
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Meetup bangalore aug31st2019
Meetup bangalore aug31st2019Meetup bangalore aug31st2019
Meetup bangalore aug31st2019
D.Rajesh Kumar
 
Ad

Recently uploaded (20)

International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Ad

Salesforce Lightning Data Services- Hands on Training

  • 1. 1 About Myself! I am Sunil Kumar 7x Salesforce Certified | Developer | Blogger Twitter : @sunil02kumar Blog: https://sunil02kumar.blogspot.in Facebook Page : SalesforceArticles I am here for Hands on training session on Salesforce events & LDS. I think it is the best way to interact & learn.
  • 2. ” Practice is the hardest part of learning, and training is the essence of transformation. 2
  • 3. Agenda ▹ Setting up Salesforce environmement for Hands on Training. ▹ Lightning Data Services Overview ▹ Creating lightning component for editing and viewing account records using Lightning Data Services. ▹ Q&A 3
  • 4. Setting up Salesforce environmement for Hands on Training. ▹ Sign up for Developer edition if you don’t have by referring below URL: https://developer.salesforce.com/gettingstarted ▹ Enable My Domain in your org (Navigate to Set Up-My Domain). ▹ After registering My Domain, deploy it for all users. 4
  • 5. Upload Static Resource ▹ Download zip file from below URL: https://goo.gl/U8nfnq ▹ Click on Setup > Static Resouce > New ▹ Specify name as “LightningEventsResources” and browse zip file. ▹ Specify “Public “ for Cache Control field and click on Save. ▹ You can refer below blog to follow steps for hands on training. https://goo.gl/DUTQfG ▹ GitHub Repository URL for complete code for Hands on Training https://goo.gl/yoM7nE 5
  • 6. Lightning Data Services6 Component (<force:recorddata /> Component (<force:recorddata /> <force:recordData aura:id="recordLoader" recordId="{!v.recordId}" mode="EDIT or VIEW" layout="FULL or COMPACT" targetRecord="{!v.recordInfo}" targetFields="{!v.fieldsInfo}" fields="Name,Owner.Name,AnnualRevenue,AccountNumber" targetError="{!v.recordError}" recordUpdated="{!c.handleRecordChanges}" />
  • 7. Create a “LDSAccountListViewApp” Lightning Application ▹ In the Developer Console, choose File > New > Lightning Application. ▹ Specify “LDSAccountListViewApp” as the app name and click submit. ▹ Specify below code in lightning app. ▹ Save the file. ▹ Click preview. 7 Place your screenshot here <aura:application extends="force:slds"> <div class="slds-text-heading_large slds-text-align_center"> Lightning Data Service Demo App </div> </aura:application>
  • 8. Create a LDSAccountEdit lightning Component8 ▹ In the Developer Console, choose File > New > Lightning Component. ▹ Specify “LDSAccountEdit” as the component name and click submit. Paste below code and Save the file. <aura:component > <aura:attribute name="recordId" type="String" required="true"/> <aura:attribute name="recordInfo" type="Object"/> <aura:attribute name="fieldsInfo" type="Object"/> <aura:attribute name="recordError" type="String"/> <aura:attribute name="currView" type="String" /> <force:recordData aura:id="recordLoader" recordId="{!v.recordId}" mode="EDIT" targetRecord="{!v.recordInfo}" targetFields="{!v.fieldsInfo}" fields="Name,Owner.Name,AnnualRevenue,AccountNumber" targetError="{!v.recordError}" recordUpdated="{!c.handleRecordChanges}" /> <div class="maincontainer"> </div> <!-- Display Lightning Data Service errors, if any --> <aura:if isTrue="{!not(empty(v.recordError))}"> <div class="recordError"> <ui:message title="Error" severity="error" closable="true"> {!v.recordError} </ui:message> </div> </aura:if> </aura:component> <lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" />
  • 9. Create a LDSAccountEdit lightning Component9 ▹ Click CONTROLLER in the right side bar of the code editor and replace code with below code and save the file.. ({ handleRecordChanges: function(component, event, helper) { var eventParams = event.getParams(); if(eventParams.changeType === "LOADED") { // record is loaded var fieldsDetails= component.get("v.fieldsInfo"); console.log("fieldsInfo is loaded successfully. TargetField"+ JSON.stringify(fieldsDetails)); var recordDetails= component.get("v.recordInfo"); console.log("recordInfo -Target Record"+ JSON.stringify(recordDetails)); console.log('Record loaded successfully'); } } })
  • 10. Lets see what we have done!!! ▹ Update the “LDSAccountListViewApp” code with below code. ▹ Save the file. ▹ Click preview. 10 Place your screenshot here <aura:application extends="force:slds"> <div class="slds-text-heading_large slds-text-align_center"> Lightning Data Service Demo App </div> <c:LDSAccountEdit recordId=“0017F000004R9C3QAK”/> </aura:application>
  • 11. Create a LDSAccountEdit lightning Component11 ▹ In order to display more account fields, replace the code inside div with class “maincontainer” with below code. <div class="maincontainer"> <div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1"> <div class="slds-form-element__control" > <lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" /> </div> </div> <div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1"> <div class="slds-form-element__control" > <lightning:input type="number" label="Annual Revenue" name="atype" value="{!v.fieldsInfo.AnnualRevenue}" formatter="currency"/> </div> </div> <div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1"> <div class="slds-form-element__control" > <lightning:input label="Account Number" name="accnum" value="{!v.fieldsInfo.AccountNumber}" /> </div> </div> <div class="slds-col--padded slds-size--1-of-1 slds-medium--1-of-1 slds-large-size--1-of-1"> <div class="slds-form-element__control" > <lightning:button variant="brand" label="Save" onclick="{!c.saveRecordHandler}"/> <lightning:button variant="brand" label="Back" /> </div> </div> </div>
  • 12. Create a LDSAccountEdit lightning Component12 ▹ Click CONTROLLER in the right side bar of the code editor and add saveRecordHandler function and save the file.. saveRecordHandler: function(component, event, helper) { component.find("recordLoader").saveRecord($A.getCallback(function(saveResult) { if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") { console.log('Record updated successfully'); }else if (saveResult.state === "ERROR") { console.log('Problem error: ' + JSON.stringify(saveResult.error)); } else { console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error)); } })); }
  • 13. Lets see what we have done!!! ▹ Update the “LDSAccountListViewApp” code with below code. ▹ Save the file. ▹ Click preview. 13 Place your screenshot here <aura:application extends="force:slds"> <div class="slds-text-heading_large slds-text-align_center"> Lightning Data Service Demo App </div> <c:LDSAccountEdit recordId=“0017F000004R9C3QAK”/> </aura:application>
  • 14. Create a LDSAccountView lightning Component14 ▹ In the Developer Console, choose File > New > Lightning Component. ▹ Specify “LDSAccountView” as the component name and click submit. ▹ Copy the code from “LDSAccountEdit” component and paste it here. ▹ Add a attribute disabled=“true” in all lightning:input tag ▹ Remove “handleRecordChanges” attribute from <force:recorddata> tag. ▹ Remove Lightning:button with label as “Save”. <lightning:input label="Account Name" name="accname" value="{!v.fieldsInfo.Name}" dsabled="true"/>
  • 15. Lets see what we have done!!! ▹ Update the “LDSAccountListViewApp” code with below code. ▹ Save the file. ▹ Click preview. 15 Place your screenshot here <aura:application extends="force:slds"> <div class="slds-text-heading_large slds-text-align_center"> Lightning Data Service Demo App </div> <c:LDSAccountView recordId=“0017F000004R9C3QAK”/> </aura:application>
  • 16. Create a Apex class to fetch Account records16 ▹ Create Apex Class “LDSAccountListViewController” to fetch latest 10 Account records from your org. public with Sharing class LDSAccountListViewController { @AuraEnabled public static List<Account> findAccounts(){ List<Account> accList = new List<Account>(); accList=[select id, name,owner.name,type,AccountNumber,AnnualRevenue,Phone from Account order by lastModifiedDate DESC Limit 10]; return accList; } }
  • 17. Create a LDSAccountListView lightning Component17 ▹ In the Developer Console, choose File > New > Lightning Component. ▹ Specify “LDSAccountListView” as the component name and click submit. <aura:component controller="LDSAccountListViewController" > <aura:attribute name="accList" type="List" /> <aura:attribute name="menu" type="List" default="View,Edit"/> <aura:attribute name="currentView" type="String" default="ListView"/> <aura:attribute name="selectedRecord" type="String" /> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <!--Section for Account List View starts--> <aura:if isTrue="{!v.currentView =='ListView'}"> <div class="slds-card"> <div class="slds-card__header slds-grid"> <header class="slds-media slds-media_center slds-has-flexi-truncate"> <div class="slds-media__figure"> <lightning:Icon iconName="standard:account" size="large" variant="inverse" /> </div> <div class="slds-media__body"> <h2> <span class="slds-text-heading_small">Accounts({!v.accList.length})</span> </h2> </div> </header> <div class="slds-no-flex"> <lightning:button variant="brand" label="New Account" /> </div> </div> <div class="slds-card__body slds-card__body_inner"> <aura:if isTrue="{!v.accList.length > 0}"> <!--display all accounts--> </aura:if> </div> <footer class="slds-card__footer">@sunil02kumar</footer> </div> </aura:if> <!--Section for Account List View ends--> </aura:component>
  • 18. Create a LDSAccountListView lightning Component18 ▹ Click CONTROLLER in the right side bar of the code editor and add doInit function and save the file.. ({ doInit : function(component, event, helper){ var action = component.get("c.findAccounts"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var apexResponse = response.getReturnValue(); //console.log('***apexResponse:'+ JSON.stringify(apexResponse)); component.set("v.accList", apexResponse); console.log('********Accounts list view loaded successfully'); }else if(state === "ERROR"){ alert('Problem with connection. Please try again.'); }}); $A.enqueueAction(action); } })
  • 19. Lets see what we have done!!! ▹ Update the “LDSAccountListViewApp” code with below code. ▹ Save the file. ▹ Click preview. 19 Place your screenshot here <aura:application extends="force:slds"> <div class="slds-text-heading_large slds-text-align_center"> Lightning Data Service Demo App </div> <c:LDSAccountListView /> </aura:application>
  • 20. Update LDSAccountListView lightning Component20 ▹ Replace <!--display all accounts--> section with below code and save file. <table class="slds-table slds-table_fixed-layout slds-table_bordered slds-table_cell-buffer"> <thead> <tr class="slds-text-title--caps"> <th scope="col">Actions</th> <th scope="col">Name</th> <th scope="col">Account Number</th> </tr> </thead> <tbody> <aura:iteration items="{!v.accList}" var="item"> <tr class="slds-hint-parent"> <td scope="row"> <lightning:buttonMenu iconName="utility:threedots" > <aura:iteration items="{!v.menu}" var="menuItem"> <lightning:menuItem label="{!menuItem}" value="{!item.Id + '---' + menuItem}" onactive="{!c.onSelectMenuItem}"/> </aura:iteration> </lightning:buttonMenu> </td> <td > {!item.Name}</td> <td > {!item.AccountNumber}</td> </tr> </aura:iteration> </tbody> </table>
  • 21. Update a LDSAccountListView lightning Component21 ▹ Click CONTROLLER in the right side bar of the code editor and add onSelectMenuItem function and save the file.. onSelectMenuItem : function(component, event, helper) { var selectedOption = event.getSource().get('v.value'); var selectedId = selectedOption.split('---')[0]; console.log('*************selectedId:'+selectedId); component.set("v.selectedRecord",selectedId); console.log('*************selectedOption:'+selectedOption); if (selectedOption.endsWith("View")) { component.set("v.currentView","RecordView"); }else if(selectedOption.endsWith("Edit")){ component.set("v.currentView","RecordEdit"); } }
  • 22. Update LDSAccountListView lightning Component22 ▹ Now we are going to display LDSAccountView and LDSAccountEdit components based selection made by user on menu item ▹ Add below markup code in LDSAccountListView component after the section for account list views and save file. <!--Section for Account record View starts--> <aura:if isTrue="{!v.currentView =='RecordView'}"> <c:LDSAccountView recordId="{!v.selectedRecord}" currView="{!v.currentView}"/> </aura:if> <!--Section for Account record View ends--> <!--Section for Account record edit starts--> <aura:if isTrue="{!v.currentView =='RecordEdit'}"> <c:LDSAccountEdit recordId="{!v.selectedRecord}" currView="{!v.currentView}" /> </aura:if> <!--Section for Account record edit ends-->
  • 23. Update LDSAccountView & LDSAccountView lightning Component23 ▹ In LDSAccountEdit component, add action to lightning:button with label as “Back”. ▹ Click CONTROLLER in the right side bar of the code editor and add goBackToListViewfunction and save the file ▹ Same way in LDSAccountView, update lightning:button with label as “Back” and add “goBackToListView” JavaScript function to controller. <lightning:button variant="brand" label="Back" onclick="{!c.goBackToListView}"/> goBackToListView : function(component,event,helper){ component.set("v.currView","ListView"); }
  • 24. Lets see what we have done!!!24 Place your screenshot herePlace your screenshot here
  • 25. 25 THANKS! Any questions? You can find me at ▹ @sunil02kumar ▹ [email protected]