LDS salesforce saturday
-
Upload
daniel-peter -
Category
Technology
-
view
257 -
download
0
Transcript of LDS salesforce saturday
LIGHTNINGDATASERVICE
DANIELPETER@DANIELJPETER
SALESFORCEMVP
22XSALESFORCECERTIFIED
BAYAREASALESFORCEDEVELOPERGROUPLEADER
LEADAPPLICATIONSENGINEER,KENANDY
WHATISIT?
• StandardcontrollerconceptfromVisualforce,reimaginedforLightningComponentFramework.
• DEVELOPERPREVIEWONLY!
• <force:recordPreview/>willbecome<lightning:record/>whenGA
WHATISIT?
https://developer.salesforce.com/docs/atlas.en-us.204.0.lightning.meta/lightning/data_service.htm
LOAD<aura:component implements="flexipage:availableForAllPageTypes,
force:lightningQuickActionWithoutHeader,
force:hasRecordId">
<aura:attributename="record"type="Object"/>
<aura:attributename="recordError"type="String"/>
<force:recordPreview aura:id="recordLoader"
recordId="{!v.recordId}"
fields="Id,Name"
targetRecord="{!v.record}"
targetError="{!v.recordError}"
/>
<ui:outputText value="{!v.record.Name}"/>
</aura:component>
SAVE<aura:component implements="flexipage:availableForAllPageTypes,
force:lightningQuickActionWithoutHeader,
force:hasRecordId">
<aura:attributename="record"type="Object"/>
<aura:attributename="recordError"type="String"/>
<force:recordPreview aura:id="recordLoader"
recordId="{!v.recordId}"
fields="Id,Name"
targetRecord="{!v.record}"
targetError="{!v.recordError}"
mode="EDIT"
/>
</aura:component>
component.find(”recordLoader").saveRecord(function(saveResult) {console.log('saveResult.state:'+saveResult.state);
});
CREATE<aura:component implements="flexipage:availableForAllPageTypes,
force:lightningQuickActionWithoutHeader,
force:hasRecordId">
<aura:attributename="record"type="Object"/>
<aura:attributename="recordError"type="String"/>
<force:recordPreview aura:id="recordLoader"
fields="Id,Name"
targetRecord="{!v.record}"
targetError="{!v.recordError}"
/>
</aura:component>
component.find("contactRecordCreator").getNewRecord("Contact",//sObject type(entityAPIname)null,//recordtypenull,//defaultrecordvaluesfalse,//skipcache?$A.getCallback(function() {})
);
DELETE
component.find("recordHandler").deleteRecord($A.getCallback(function(saveResult) {
var goToObjectHome =$A.get("e.force:navigateToObjectHome");
goToObjectHome.setParams({"scope":saveResult.entityApiName});
goToObjectHome.fire();
}));
CRUDSUMMARY
Load:hasrecordId,don’tneedJSconSave:buildsonload.NeedsJSconwithsaveRecord functionCreate:norecordId.CallgetNewRecord functiontosetdefaultvalues.Nowyouareinsavemode.Delete:Load,justneedId,calldeleteRecord
FUTURE
• GA<lightning:record />• <lightning:recordUI />(datawithUI)• <lightning:recordCollection />(bulkrecords)• updatestriggeredfromserver
BENEFITS
• Muchlesscode.NoApex.NoSOQL.JSnotneededforloading.• CRUD/FLS/SHARINGisrespected• Cachingimprovesperformance.Fewerroundtripstoserver.Componentssharethesamerecord.• Betterofflinesupport.
DRAWBACKS
• Needstobeinthecontextofarecord.Lightningaction/page.• Doesn’tsupportrelationships.• Doesn’tsupportbulkoperations.Singlerecord.• CanonlyquerybyId• Nosupportfortransactionscontrol,rollbacks.• NoUIinvolved.Justadataobject.Needtouseui:input/outputstill.
RESOURCES
• SalesforceDeveloperDocs:• https://developer.salesforce.com/docs/atlas.en-us.204.0.lightning.meta/lightning/data_service.htm
• BuildAppsFasterwithLightningandWinter'17• https://youtu.be/BK-jYea5ogo
• LightningDataService- BuildLightningcomponentsWithoutApex!(DF16)• https://youtu.be/zehVwn_9DmA
• PreviewingtheLightningDataService(SystemdotDebugpodcast)• https://youtu.be/_5kenqeEi0k