0

I'd like to show the value of the formula text field. The formula text field is {!v.opptyOwnerName.Account_Name__c} but on the lightning page the value doesn't appear. FYI the Accounts {!v.opptyOwnerName.Accounts_KYC_Approved__c} field also is a Formula Text field.(see image below) Any thoughts?

Formula: IF(LEN(Account.Name)>50, LEFT(Account.Name,50),Account.Name) enter image description here

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="showOpportunity" type="Object"/> <!-- used for target record -->
<aura:attribute name="opptyOwnerName" type="Object"/><!-- used for targetFields-->
<aura:attribute name="recordError" type="String" 
                description="An error message bound to force:recordData"/>
<force:recordData aura:id="OpptyRecord"
                  recordId="{!v.recordId}" 
                  targetError="{!v.recordError}"
                  targetRecord="{!v.showOpportunity}"
                  targetFields="{!v.opptyOwnerName}"
                  layoutType="FULL"
                  mode="EDIT"
                  recordUpdated="{!c.recordUpdated}"/>
     <!-- recordId displays the record you currently are on,
targetfields must be specified to display later or use layout=FULL -->

<lightning:card iconName="standard:opportunity" title="{!v.opptyOwnerName.Name}" >

    <aura:if isTrue="{!v.opptyOwnerName.StageName == '1 - Prospect'}">
        <div class="slds-p-horizontal--small">

        <p class="slds-text-heading--small">
            <b>Account:</b> <lightning:formattedText  value="{!v.opptyOwnerName.Account_Name__c}" /></p>
        <p class="slds-text-heading--small">
            <b>Accounts KYC Approved:</b> <lightning:formattedText value="{!v.opptyOwnerName.Accounts_KYC_Approved__c}" /></p>
        <p class="slds-text-heading--small">
            <b>Pricebook:</b> <lightning:formattedText value="{!v.opptyOwnerName.Pricebook2Id}" /></p>
        </div>
    </aura:if>

<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
    {!v.recordError}
</div>

4
  • 1
    Hi. It would be super helpful if you could also include the actual formula for this field - I would suspect that the value is evaluating to something blank but can't be sure since you didn't provide this detail.
    – Phil W
    Commented Nov 7, 2019 at 20:29
  • Sorry about that, here is the formula: Data Type FormulaThis formula references multiple objects IF(LEN(Account.Name)>50, LEFT(Account.Name,50),Account.Name) Please keep in mind the value appears on the page layout.
    – user69530
    Commented Nov 7, 2019 at 21:15
  • Make sure that the field and its value is in opptyOwnerName. You said that the field is in the layout and that is important too when using force:recordData Commented Nov 8, 2019 at 8:41
  • Thanks that was the problem! I didn't know it had to be in the layout! Is it possible to pull data from the Opportunity owner such as display their image, phone , email?
    – user69530
    Commented Nov 8, 2019 at 19:27

1 Answer 1

0

I had to add the field to the layout for the field value to display in the lightning card.

2
  • The canned response doesn't do so well in this situation. I do think going into a bit more detail would help this answer.
    – Derek F
    Commented Nov 9, 2019 at 1:32
  • @DerekF The field had to be added to the page layout...that's what worked for me. I would have posted the code if I made a change to the code. Do you want me to show how to add fields to page layouts?
    – user69530
    Commented Nov 12, 2019 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .