Apex controller:

public class plController {
public static integer IsDataAvailable() {
    integer count=[select count()   FROM Bank__c where IsActiveFlag__c=: true and BankCompleteFlag__c=: true and  BankStatus__c!='Incomplete'];
    return count;
public static List<PipelineResponse> getBankOrigination() {
    List<PipelineResponse> objRes=new List<PipelineResponse> ();
    List<Bank__c> obj=new List<Bank__c>();
    List<Client__c> objallclient=new List<Client__c>();
    List<Bank__c> objBankid=new List<Bank__c>();  
        objBankid=[SELECT Id FROM Bank__c where IsActiveFlag__c=: true and BankCompleteFlag__c=: true and BankStatus__c in('Proposal','Waiting for Full Package') ];            
        obj=  [SELECT Id,Name,BankNumber__c,BankStatus__c ,LastModifiedDate FROM Bank__c where IsActiveFlag__c=: true and BankCompleteFlag__c=: true and BankStatus__c in('Proposal','Waiting for Full Package') ORDER BY BankStatus__c];
        objallclient=[SELECT Name,First_Name__c, Last_Name__c,BankId__c FROM Client__c where Primary_Client_for_the_Bank__c =: true and BankId__c IN:objBankid  ];

        for(Bank__c lc:obj)            
            PipelineResponse obj1=new PipelineResponse();
            if(lc.BankNumber__c ==null || lc.BankNumber__c =='')

            for(Client__c c:objallclient)  
                    obj1.FullName= c.Name;
       /****/obj1.BankStatus=lc.BankStatus__c; //How can I get a value            
                                     instead of API Name for this Picklist
    catch(exception e){}
    return objRes;  

Lightning Component:

<aura:iteration items="{!v.Bank}" var="Bank">                                            
<tr >    
<td data-label="Bank Number"  >
    <div class="slds-truncate table-body">            
        <b><a id = "{!Bank.Bankid}" onclick="{!c.PipeLineMenu}">{!Bank.BankNumber}</a>
<td data-label="Name" >
    <div class="slds-truncate table-body"><b>
        {!Bank.FullName}</b></div>    </td>
<td data-label="Status"  >
    <div class="slds-truncate table-body"><b>{!Bank.BankStatus} /***/
<td data-label="Bank Status DateTime"  >
    <div class="slds-truncate table-body"><b>{!Bank.BankDate}

BankStatus__c is a Picklist field, I get the API value as output, how can I get field label as output. Thanks!


There's a way to get picklist label via Schema.

For example from official blog:

Schema.DescribeFieldResult fieldResult = Account.PicklistField__c.getDescribe();
List<Schema.PicklistEntry> values = fieldResult.getPicklistValues();
for( Schema.PicklistEntry v : values) {
    System.debug('Picklist Value Label:' + v.getLabel());
    System.debug('Picklist API Name:' + v.getValue());

In your case.

  1. Get DescribeFieldResult from Bank__c.BankStatus__c.
  2. Make a Map to store Api <-> Label relationship.
  3. Get Label from the map.


Hope it helps.

Code Edit Example:

Put this before loop

    // Made a Map to store ApiName <-> Label relationship
    Schema.DescribeFieldResult fieldResult = Bank__c.BankStatus__c.getDescribe();
    List<Schema.PicklistEntry> values = fieldResult.getPicklistValues();
    Map<String, String> valueLabelMap = new Map<String,String>();
    for( Schema.PicklistEntry v : values) {
        valueLabelMap.put(v.getValue(), v.getLabel());

    for(Bank__c lc:obj)            

Then use the Map to get Label like this:

    obj1.BankStatus = valueLabelMap.get(lc.BankStatus__c);
| improve this answer | |
  • Thank you Kealsalas it is working, but how can I use it in my code?, sorry I am new to coding, can you help me with this, thanks! – Sfdc learner Apr 8 '18 at 16:45
  • The Example was added. Please try it. – Kealsalas Apr 9 '18 at 0:30
  • Awesome!!!!!!! Thank you so much @Kealsalas . Just a small change, we need to add valueLabelMap.put(v.getValue(), v.getLabel()); – Sfdc learner Apr 9 '18 at 3:59
  • Oops, my mistake. Sorry for that. Fixed.@Sfdc learner – Kealsalas Apr 9 '18 at 5:30

Another option would be to use toLabel() function in your SOQL statement as described in this answer How to query 'Value' of a picklist rather than the 'API NAME', using SOQL?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.