function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravichandra sindheRavichandra sindhe 

Salesforce Custom settings

I am planning to use custom settings..need a help

How to fetch a list from customer settings to my lighting component combo box

List of Colour : 
Red
Green
Blue
Raj VakatiRaj Vakati
You can able to do this  .. 

Create a custom setting and store the values in the Custom_Settings__c  (Red
Green
Blue etc) and use this code ..But i will suggest to use the custom metadata instead of custom settings 

 
public class GetValuesFromCustomSetting {
    @AuraEnabled
    public static List<String> getDepartment () {
        Set<String> uniqueValues = new Set<String>();
        List<Custom_Settings__c> results=[Select Id, Name from Custom_Settings__c];
        for(Custom_Settings__c c : results){
                uniqDepartment.add(c.Name); 
        }
        List<String> finalResult =  new List<String>();
        finalResult.addAll(uniqDepartment); 
        finalResult.sort();
        return  finalResult;
    }
    
    
    
    
}
 
<aura:component controller="GetValuesFromCustomSetting">
    <aura:attribute name="statusOptions" type="List" default="[]"/>
    <aura:attribute name="contacts" type="Contact[]" default="[]"/>
    
    <aura:handler name="init" value="{! this }" action="{! c.loadOptions }"/>
    <lightning:combobox aura:id="selectItem" name="status" label="Status"
                        placeholder="Choose Status"
                        value="new"
                        required="true"
                        dropdownAlignment="right"
                        variant="standard"
                        messageWhenValueMissing="You Must Select the Value"
                         
                        options="{!v.statusOptions}"/>
    
    
</aura:component>
 
({
    loadOptions: function (cmp, event, helper) {
        var options = [
        ];
        var action = cmp.get("c.getDepartment");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var arr = response.getReturnValue() ;
                arr.forEach(function(element) {
                    options.push({ value: element, label: element });
                });
                cmp.set("v.statusOptions", options);
                
            }
            
            
        });
        $A.enqueueAction(action);
        
    },
     
})

 
Raj VakatiRaj Vakati
Its wokring ??