Amit Kundu
Amit Kundu

Reputation: 21

How to order custom setting records like all capital letter value come in last in salesforce

We are getting this custom setting value in aura component

Apex class below

@AuraEnabled public static AP_ApplicantSpaceFooterWrapper getdisclaimerCS(){

AP_ApplicantSpaceFooterWrapper footerDetailsWrapper  = new AP_ApplicantSpaceFooterWrapper();

List<CS_DisclaimerLink__c> disclaimerLinkList = CS_DisclaimerLink__c.getall().values();

footerDetailsWrapper.disclaimerLinkCSList = disclaimerLinkList;
footerDetailsWrapper.userLanguage = UserInfo.getLanguage();

return footerDetailsWrapper;

aura componnet helper method where we are setting the attribute from above class method.

({ doInit : function(component, event, helper) {

    helper.callServer(
        component, 
        "c.getdisclaimerCS", 
        function(response){
            console.log('response: '+response);
            if(!$A.util.isEmpty(response)){                    
                component.set("v.disclaimerLinksCS", response);
            }
        }
    );
  
}

})

On UI we are getting these value like below enter image description here

but we want that CGU(capital letter ) one only comes in last rest all are correct in order.

Screenshot of custom setting records is below enter image description here

Upvotes: 0

Views: 208

Answers (1)

eyescream
eyescream

Reputation: 19637

Why don't you add a column to the custom setting with SortOrder__c and fetch them with plain old SOQL query with ORDER BY... instead of CS_DisclaimerLink__c.getall()?

I mean if you really want you probably can pull it off using a helper wrapper class and implements Comparable in the Apex before returning it to Aura but sounds like an overkill.

Edit

Your "@auraenabled" isn't even marked "cacheable=true", in a way you don't have "right" to talk about performance on SF platform. "Cacheable" would make aura fetch valueonly once, not on every rerender, making the getall vs soql dilemma less important.

But if you're really paranoid - add the column with sort order, fetch them with getall, put as a field in helper class that implements Comparable and sort in memory rather than with soql.

Upvotes: 0

Related Questions