Below is my code:

<aura:component controller="AccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"  >
    <ltng:require styles="/resource/slds221/assets/styles/salesforce-lightning-design-system.min.css" />
    <aura:attribute name="edit" type="Boolean" default="true"/>
    <aura:attribute name="save" type="Boolean" default="false"/>
    <aura:attribute name="cancel" type="Boolean" default="false"/>
    <aura:attribute name="Account" type="Account" default="{ 'sobjectType': 'Account' }"/>
    <aura:attribute name="recordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
        <aura:if isTrue="{!v.edit}">
            <lightning:button variant="neutral" label="Edit Info" class="slds-align_absolute-center" onclick="{!c.handleEdit}"/>
        <aura:if isTrue="{!v.save}">
            <lightning:button variant="neutral" label="Save Info" class="slds-align_absolute-center" onclick="{!c.handleSave}"/>
        <aura:if isTrue="{!v.cancel}">
            <lightning:button variant="neutral" label="Cancel" class="slds-align_absolute-center" onclick="{!c.handleCancel}"/>
    <div class="slds-form slds-form_stacked">
        <div class="slds-form-element">
            <div class="slds-form-element__control">
                <lightning:select name="selectItem" label="Process Item" disabled="{!!v.save}">
                    <option value="1">Yes</option>
                    <option value="2">No</option>
            <label class="slds-form-element__label" for="input-id-03">Process Contact ?</label>
            Save: {!v.Account.Contact__c}
            <aura:renderIf isTrue="{!v.save}">
                <div class="slds-form-element__control">
                    <force:inputField value="{!v.Account.Contact__c}" class="foo" >{!v.Account.Contact__c}</force:inputField>
            <aura:renderIf isTrue="{!!v.save}">
                <div class="slds-form-element__control">
                  <force:outputField aura:id="accountLookupOutput" value="{!v.Account.Contact__c}"/>

My Js.

    doInit : function(component, event, helper) {
        var getaccountdata = component.get("c.getAccount");
        getaccountdata.setParams({ "Id": component.get("v.recordId")});
        getaccountdata.setCallback(this, function(response){      
            var state = response.getState();
            if (state === 'SUCCESS'){

Apex Code:

    public static Account getAccount(String Id) {
        return [select Id,Contact__c from Account WHERE ID =:Id Limit 1];

I get the associated data for that account and then i set it back to the account attribute.

But on page load I dont see the value in force:outputfield even though that account has that value populated in field.

Can anyone help me on this? if I missed something here I tried to put force:output field at the top as well but still the same its blank

While selecting any value in the force:inputfield, the outputfield gets populated but not while the page loads

enter image description here

  • Are you getting any error(s)? Mar 25 '18 at 15:18
  • No nothing in the console i checked. From the input field when i select any value i see that gets populated in output field but on the page load, nothing appears it is just blank
    – Quddus
    Mar 25 '18 at 15:20
  • 1
    Share the Apex code as well; Mar 25 '18 at 15:39
  • just pasted in the question
    – Quddus
    Mar 25 '18 at 15:49

I finally got the issue, in the apex controller for the lookup fields, I need to use the related fields as well

    public static Account getAccount(String Id) {
        return [select Id,Contact__r.Name from Account WHERE ID =:Id Limit 1];

Thanks @itzmukeshy7

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.