Using Lightning Data Service in Action Overrides

Introduction:-

In this blog post, I am going to explain how to use the Lightning data services in Lightning component standard action overrides.  Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you.  Lightning Data Service as the Lightning Components version of the Visualforce standard controller. To override the standard action with lightning component, the component must implements lightning:actionOverride interface.

Override Edit Action 

To override the edit action you need to implement lightning: actionOverride interface and update the record using Lightning Data Service by calling saveRecord on the force:recordData component, and pass in a callback function to be invoked after the save operation completes.


 

Override View Action

To override the edit action you need to implement lightning: actionOverride interface and Loading a data by using the Lightning Data Service.  To load a record using Lightning Data Service, add the force:recordData tag to your component. In the force:recordDatatag, specify the ID of the record to be loaded, a list of fields, and the attribute to which to assign the loaded record. 

 

 

Lightning Components Actions Override

Introduction:-

In this blog, I am going to show how to override the standard action for the lightning experience by using lightning component. To override the standard action with the lightning component you need to implement lightning:actionOverride interface. You can override the View, New, Edit, and Tab standard actions on most standard and all custom components. Overriding standard actions allows you to customize your org using Lightning components, including completely customizing the way you view, create, and edit records.There are six standard actions available on most standard and all custom objects: Tab, List, View, Edit, New, and Delete.Components you plan to use as action overrides usually need details about the object type they’re working with, and often the ID of the current record. Your component can implement the following interfaces to access those object and record details.Add the force: hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on.Add the force: hasSObjectName interface to a Lightning component to enable the component to be assigned the API name of current record’s sObject type. The sObject name is useful if the component can be used with records of different sObject types, and needs to adapt to the specific type of the current record.

New Action Override

Create a new lightning component with the below code

Go to object manager and override the new  button action as shown below 

View Action Override

Crate a new lightning component with below code

Override the view action as shown below

Override Edit Action

Create a new Lightning component with below code

Override the edit action as shown below

 In this example, i used the lightning:recordEditForm and lightning:recordViewForm components to wrap the form for edit and view modes.

Lightning component forceChatter examples

In this blog I am going to show how to use salesforce forceChatter:** components and how its use them to create your own components show the feed. A forceChatter: feed component represents a feed that’s specified by its type. Use the type attribute to display a specific feed type. The strategy used to find items associated with the subject. Valid values include Bookmarks, Company, DirectMessages, Feeds, Files, Filter, Groups, Home, Moderation, Mute, News, PendingReview, Record, Streams, To, Topics, UserProfile.

For example, set type=” groups” to display the feed from all groups the context user either owns or is a member of.

You can also display a feed depending on the type selected. This example provides a drop-down menu that controls the type of feed to display

Here is the app

 

Lightning Accordion Component Example

In this blog, I am going to explain how to use salesforce lightning: accordion component. A  lightning:accordion component groups related content in a single container. Only one accordion section is expanded at a time. When you select a section, it’s expanded or collapsed. Each section can hold one or more Lightning components. In this blog, I am going to show the list of books by its category as an accordion.

Apex Class

Lightning Component

 

You can see final accordion in the below image.

 

lightning:carousel example

In this blog, I am going to explain how to use lightning: carousel example. Here I am using to display the user chatter profile image to display as the carousel.A lightning: carousel component displays a series of images in a single container. This example creates a basic carousel with three images. Auto-scrolling is enabled by default, and every image stays active for 5 seconds before moving on to the next one.

Apex Class

Lightning Component 

 

Simple App for testing