Custom Actions in lightning:listView in Salesforce

Custom Actions in lightning:listView in Salesforce

1. Create a List View. Get the List API Name.

2. Create a Custom Lightning Component.

Component:

  1. <aura:component implements=“force:appHostable” >  
  2.       
  3.     <div class = “slds-box slds-theme_default”>   
  4.         <div class=“slds-clearfix”>  
  5.         <div class=“slds-float–right”>  
  6.             <lightning:button label=“New” title=“New” onclick=“{! c.handleClick }”/>  
  7.         </div>  
  8.         </div>  
  9.           
  10.         <div>  
  11.             <lightning:listView aura:id=“listViewExtEmps”  
  12.                                 objectApiName=“Employee__c”  
  13.                                 listName=“External_Employees”  
  14.                                 rows=“5”  
  15.                                 showSearchBar=“true”  
  16.                                 showActionBar=“false”  
  17.                                 enableInlineEdit=“true”  
  18.                                 showRowLevelActions=“true”/>  
  19.         </div>  
  20.           
  21.     </div>  
  22.       
  23. </aura:component>  



Component Controller:

  1. ({  
  2.       
  3.     handleClick : function (cmp, event, helper) {  
  4.           
  5.         var createRecordEvent = $A.get(‘e.force:createRecord’);  
  6.         if ( createRecordEvent ) {  
  7.               
  8.             createRecordEvent.setParams({  
  9.                 ‘entityApiName’‘Employee__c’,  
  10.                 ‘recordTypeId’ : ‘0123i000000HSiWAAW’  
  11.             });  
  12.             createRecordEvent.fire();  
  13.               
  14.         } else {  
  15.               
  16.             /* Create Record Event is not supported */  
  17.             alert(“Record creation is not supported”);  
  18.               
  19.         }  
  20.           
  21.     }  
  22.       
  23. })  

3. Create a Lightning Tab.

Output:

Leave a Reply