Summer ’17 Salesforce Two New Cool Lightning Features


With new Summer '17 release Salesforce introduced some new cool features for Lightning, I really liked below two features and they are my top pick for this blog posting
1. Standard Action Overrides
2. Lightning Data Service (Currently in Beta)

Here is the Link for the article from Salesforce that has detailed explanation on each of these new features.

Standard Action Overrides:

Until Summer '17 release we only had an option to override standard actions with visualforce page but now we have an new option to override any of these four standard actions (New, View, Edit and Tab) with a custom lightning component, just by using one powerful line of code "lightning:actionOverride". Lets just create a sample Lightning Component to override Account standard actions.

Below is my Lightning Component Code:
 <aura:component implements="lightning:actionOverride,force:hasSObjectName,force:hasRecordId">    
   <aura:if isTrue="{!v.sObjectName != 'Account'}">  
     <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert">  
       <span class="slds-assistive-text">Improper override selected error</span>  
       <h1>Oops Current object is {!v.sObjectName} and this override works only for Account Object!</h1>  
     </div>  
   </aura:if>  
   <aura:if isTrue="{!v.sObjectName == 'Account'}">  
     <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert">  
    <center><ui:button label="Click Me" aura:id="button" press="{!c.alertMsg}"/></center>  
     </div>  
   </aura:if>   
 </aura:component>  

Below is my Component Controller Code to display simple alert message:
 ({  
  alertMsg : function(component, event, helper) {  
     alert('Current Object Name: ' + component.get("v.sObjectName"));  
  }  
 })  

Once we have our component created, we should be able to see this component being available for action override and this makes it such a cool feature to be able to use any Lightning Component as a standard action override though we have some below considerations with this feature!

Some Considerations when building action override Lightning components (From Salesforce Documentation):
a. Components always display as a page, not a modal or panel (that is, not as a pop-up/smaller screen).
b. Developers need to provide a complete user interface for overrides (that is, all buttons/navigation options for users, like Save or Cancel, and so on).
c. In Summer ’17, Lightning component action overrides apply only in Lightning Experience and Salesforce1.



Lightning Data Service (Currently in Beta):

One of main advantages with Lightning Data Service is to avoid using Apex in your Component and this make Lighting Component as independent of controller code.
With this new Lightning Data Services we can Load, Edit, Save, Create, Update, and Delete a given record just by implementing "force:recordData". All changes are going to be synchronous and at the same time LDS also respect all sharing and field-level settings which is going to be Lighting platforms biggest plus!

Comments

Popular posts from this blog

Displaying Toast Message from Modal in Lightning Components

Lightning Component to display dynamic sObject data

Lightning RecordForm - An enhanced Lightning Data Service