Lightning Components in Quick Actions

Lightning Components are the go to things in almost everything in Salesforce Development nowadays. There are so many things changed from Salesforce classic to Lightning. One of which is below :-

What has retired ?

Custom button on details page with open Visualforce or execute JavaScript.

What is the solution ?

Actions. With actions you can create a record, update record, Open Visualforce or Lightning Component and etc. While some us will think there is still Visualforce pages available in action, while some of us want to explore lightning.

Steps to use Lightning Component in Actions and other useful things

Create lightning component and add force:lightningQuickAction (this will have Cancel button by default) or force:lightningQuickActionWithoutHeader

<aura:component controller="RS_SearchPropertyCntrl" implements="force:lightningQuickAction,force:hasRecordId" >

To get the record id of the current object in the lightning component add force:hasRecordId

// This will give you record if which can be used to query or filter records
// In helper or controller
component.get("v.recordId");

Closing action manually

var dismissActionPanel = $A.get("e.force:closeQuickAction");
dismissActionPanel.fire();

Showing a toast message

var toastEvent = $A.get("e.force:showToast");
 toastEvent.setParams({
 "title": "Success!",
 "message": "The records has been saved"
 });
 toastEvent.fire();

Refreshing the main view if required

$A.get('e.force:refreshView').fire();

Now just create the Action choose Lightning Component add action on the page layout and you are good to go..

Sample lightning component action which I created for providing general idea

screen-shot-2017-02-26-at-7-23-09-pm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s