function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vikas U MishraVikas U Mishra 

Not able to set value for force:inputfield which is standard account lookup field on Opportunity Object

We are setting value force:inputField for Account Lookup field on Opportunity object for Lightning Component.

 
component.set("v.newOpportunity.AccountId", accountDetailsId);
                
                // we need this for the actual 'pill' in the lookup field
                var values = [{
                    type: 'Account',
                    id: accountDetailsId,
                    label: component.get('v.account.Name'),
                    icon : {
                        url:'/img/icon/t4v35/standard/account_120.png',
                        backgroundColor:'A094ED',
                        alt:'Account'
                    }
                }];
                
                component.find("accountName").get("v.body")[0].set("v.values", values);

Do we have any other workaround for this? 
Even after setting value, I am getting undefined for following code.
component.find("accountName").get("v.body")[0].get("v.values")


Component side code:

<div class="slds-form-element">
            <label class="slds-form-element__label"
                   for="accountName">Account Name: </label>
            <div class="slds-form-element__control">     
                <force:inputField aura:id="accountName" value="{!v.newOpportunity.AccountId}" required="true"/>
            </div>
        </div>