Hey guys, today in this post we are going to learn about How to fetch all custom settings values using Apex and Iterate the custom list values on lightning component after that custom settings navigation through edit/back button in custom setting Salesforce.
How to get value, view edit list, or back navigation button of custom settings salesforce
Files we used to fetch all custom settings values in this post example
customSettingCmp.cmp | Lightning Component | It is used for create a table for Iterate the custom setting list values on lightning component |
customSettingCmpController.js | JavaScript Controller File | It is hold Javascript doInit functionality. |
customSettingCmpHelper.js | JavaScript Controller Helper File | It is hold for Javascript Helper Function to get Custom setting values from apex method |
customSettingCmpCtrl.apxc | Apex Class Controller | It is used for get List of Custom Setting values from Apex Class Method |
Live Demo
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
- Find the below steps
Create Lightning Component
Step 1:- Create Lightning Component : customSettingCmp.cmp
From Developer Console >> File >> New >> Lightning Component
customSettingCmp.cmp [Lightning Component File]
|
<aura:component controller="customSettingCmpCtrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="awsList" type="List"/>
<aura:attribute name="cmpStr" type="String" default="list"/>
<lightning:card>
<div class="slds slds-p-around_medium">
<aura:if isTrue="{!v.cmpStr == 'list'}">
<table class="slds-table slds-table_bordered slds-table_col-bordered">
<thead>
<tr>
<th class="slds-hide">Id</th>
<th>View Log</th>
<th>Name</th>
<th>API Endpoint</th>
<th>Other Attribute Three</th>
<th>Other Attribute Four</th>
<th>Other Attribute One</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.awsList}" var="item">
<tr>
<td class="slds-hide">{!item.Id}</td>
<td><a id="{!item.Id}" onclick="{!c.navigateToDetail}">View Log</a></td>
<td>{!item.Name}</td>
<td>{!item.API_Endpoint__c}</td>
<td>{!item.Other_Attribute_Three__c}</td>
<td>{!item.Other_Attribute_Four__c}</td>
<td>{!item.Url_Attribute_One__c}</td>
</tr>
</aura:iteration>
</tbody>
</table>
<aura:set attribute="else">
<div class="slds-page-header">
<div class="slds-grid slds-gutters">
<div class="slds-col slds-size_8-of-12">
<div class="slds-media">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-opportunity" title="opportunity">
<lightning:icon iconName="custom:custom34" title="Debug Logs" />
<span class="slds-assistive-text">Debug Log</span>
</span>
</div>
<div class="slds-media__body">
<div class="slds-page-header__name">
<div class="slds-page-header__name-title">
<h1>
<span class="slds-page-header__title slds-truncate" title="Mobile App Logs">Api Log Id</span>
</h1>
</div>
</div>
</div>
</div>
</div>
<div class="slds-col slds-size_4-of-12 slds-text-align_right">
<lightning:button variant="brand" label="Back" name="btnBack" title="Back" onclick="{! c.navigateToList}" />
</div>
</div>
</div>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_6-of-12 slds-p-horizontal_small slds-m-bottom_small"><lightning:input type="text" aura:id="awsName" name="awsName" label="Name" value="{!v.awsList[0].Name}"/></div>
<div class="slds-col slds-size_6-of-12 slds-p-horizontal_small"><lightning:input type="text" aura:id="awsEndpoint" name="awsEndpoint" label="Endpoint" value="{!v.awsList[0].API_Endpoint__c}"/></div>
</div>
</aura:set>
</aura:if>
</div>
</lightning:card>
</aura:component>
Create JavaScript Controller
Step 2:- Create Lightning Component : customSettingCmpController.js
From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller
customSettingCmpController.js [JavaScript Controller]
|
({
doInit : function(component, event, helper) {
helper.doInitHelper(component);
},
navigateToDetail:function(component, event,helper){
var navId = event.target.getAttribute('id');
component.set("v.cmpStr",'detail');
component.set("v.viewLogId",navId);
},
navigateToList:function(component, event,helper){
var navId = event.target.getAttribute('id');
component.set("v.cmpStr",'list');
},
})
Create JavaScript Helper
Step 3:- Create Lightning Component : customSettingCmpHelper.js
From Developer Console >> File >> New >> Lightning Component >> JavaScript Helper
customSettingCmpHelper.js [JavaScript Helper File]
|
({
doInitHelper : function(component, event, helper) {
var action = component.get("c.getCustomSettingLogs");
action.setCallback(this, function(response){
var state = response.getState();
if(state == "SUCCESS"){
var result = response.getReturnValue();
component.set('v.awsList', result);
}
});
$A.enqueueAction(action);
},
})
Create Apex Class Controller
Step 4:- Create Apex Class : customSettingCmpCtrl.apxc
From Developer Console >> File >> New >> Apex Class
customSettingCmpCtrl.apxc [Apex Class Controller]
|
public class customSettingCmpCtrl {
@AuraEnabled
public static List<aws_integration__c> getCustomSettingLogs(){
//aws_integration__c awsIntgrt = aws_integration__c.getValues(constantsCtrl.amazonS3Manage);
List<aws_integration__c> awsIntgrt = aws_integration__c.getAll().values();
system.debug('awsIntgrt ' + awsIntgrt);
RETURN awsIntgrt;
}
}
Further post that would you like to learn in Salesforce
What is use of custom settings in Salesforce?
Custom settings are similar to custom objects in that they let you customize org data. Custom settings also let you distinguish particular users or profiles based on custom criteria.
How do I change custom settings in Salesforce?
Go to Setup | Home | Data | Schema Settings and Enable 'Manage List Custom Settings Type'.
Can we update custom setting in Apex?
We can query or we can use getInstance() to get the value and then we can use update keyword to update the Custom Settings value.
Related Topics | You May Also Like
Our Free Courses β
π Get Free Course β
π Salesforce Administrators π Salesforce Lightning Flow Builder π Salesforce Record Trigger Flow Builder |
π Get Free Course β
π Aura Lightning Framework π Lightning Web Component (LWC) π Rest APIs Integration |