force:hasRecordId in Custom Lightning Component development
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 ....
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 ....
Sample Code: Component: <aura:component implements="force:appHostable" controller="OpportunitySearchController"> <aura:attribute name="oppty" type="Opportunity" default="{ 'sobjectType': 'Opportunity'}"/> <aura:attribute name="columns" type="List"/> <aura:attribute name="opportunityList" type="Opportunity[]"/> <aura:attribute name="PaginationList" type="Opportunity[]"/> <aura:attribute name="startPage" type="Integer" /> <aura:attribute name="endPage" type="Integer"/> <aura:attribute name="totalRecords" ....
AccountList.cmp <aura:component controller="AccountListController" implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" > <aura:attribute type="Account[]" name="acctList"/> <aura:attribute name="mycolumns" type="List"/> <aura:attribute name="sortedBy" type="String" ....
Sample Code: Component: <aura:component implements="force:appHostable" > <lightning:fileUpload label="Attach receipt" name="fileUploader" multiple="true" accept=".pdf, .png" recordId="0016A00000MneVlQAJ" onuploadfinished="{!c.handleUploadFinished}" /> </aura:component> Controller: ({ handleUploadFinished: function (cmp, event) { var uploadedFiles = event.getParam("files"); alert("Files uploaded"); ....
AccountList.cmp: <aura:component controller="AccountListController" implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" > <aura:attribute type="Account[]" name="acctList"/> <aura:attribute name="mycolumns" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/> <lightning:datatable data="{! v.acctList }" columns="{! v.mycolumns }" keyField="id" hideCheckboxColumn="true"/> </aura:component> AccountListController.js ({ fetchAccounts : function(component, ....
To create a record using Lightning Data Service, declare force:recordData without assigning a recordId. Next, load a record template by calling the getNewRecord function on force:recordData. Finally, apply values to ....
force:navigateToURL can be used for Navigation in Salesforce Lightning. AccountList.cmp: <aura:component controller="AccountListController" implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" > <aura:attribute type="Account[]" name="acctList"/> <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/> <table class="slds-table slds-table_bordered slds-table_cell-buffer"> <thead> <tr class="slds-text-title_caps"> <th scope="col"> ....
Sample App: <aura:application extends="force:slds"> <c:AccountList /> </aura:application> Lightning Aura Component: AccountList.cmp: <aura:component controller="AccountListController"> <aura:attribute type="Account[]" name="acctList"/> <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/> <table class="slds-table slds-table_bordered slds-table_cell-buffer"> <thead> <tr class="slds-text-title_caps"> <th scope="col"> <div ....
Conditional rendering allows us to hide and show. We have to use 1. aura:if For showing contents when the condition is true. 2. aura:set For showing contents when the condition ....
This is a know issue. Check the below link https://developer.salesforce.com/forums/?id=906F0000000AvH7IAK Raise a Salesforce.com support ticket to know more.