2

To get picklist's field value from sObject using SOQL I can use toLabel(FIELD_NAME). Is it possible to do the same with force:recordData component?

enter image description here

  • The term you're looking for is "label". The API name is the value of the picklist field. Despite the fact that the Salesforce UI makes it confusing and calls it "Value". – Charles T Dec 4 '18 at 13:11
4

Assign an object to targetRecord as well, e.g.:

<force:recordData aura:id="recordLoader"
  recordId="{!v.recordId}" targetRecord="{!v.fullRecord}"
  targetFields="{!v.simpleRecord}"
  targetError="{!v.recordError}"
  recordUpdated="{!c.handleRecordUpdated}"
  />

You'd retrieve the picklist label as: {!v.fullRecord.fields.PicklistName.displayValue}

| improve this answer | |
  • 1
    Thank you Charles, using targetRecord attribute solves the problem. – Piotr Błach Dec 4 '18 at 13:21
  • Hi @Charles - I have a similar requirement but here I need to refer to pickilst field values not picklist field label. I am using force:recordData targetFields attribute for this and using it in this way - {!v.simpleRecord.Address_Type__c} - but it returns english value only even in Turkish locale. Can you please help in this – Monalisa Das Mar 13 '19 at 13:47
  • Picklist options have only one value. Labels are the ones that get translated, not values. – Charles T Mar 13 '19 at 14:03

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.