0

I am trying to set the value of a 'force:inputField' lookup field dynamically, but it is not working. On click of the edit button, the record edit page gets open, but the Account value does not get set. All other values are getting set. But we have a problem for the force:inputField lookup field.

We have tried out the workaround given in the following the link: https://help.salesforce.com/articleView?id=000322074&language=en_US&type=1&mode=1 But this is not working.

  1. Component

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:actionOverride" access="global" >  <aura:attribute name="opportunity"  type="Opportunity"  default="{ 'sobjectType': 'Opportunity' }"/><aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  <div class="slds-form-element__control"><force:inputField class="form-control" aura:id="account_name" value="{!v.opportunity.AccountId}"  /> </div></aura:component> 
    
  2. Controller:

    doInit: function(component, event, helper) {
        var value = [{
            type: 'Account',
            id: "0015400000GldOZAAZ",
            label: "navigate",
        }];
        component.find("account_name").get("v.body")[0].set("v.values", value);
    }
    

How to resolve this issue?

1 Answer 1

0

you should use 'sobjectType': 'Account', not a type for your value java script

var value = [{
        sobjectType: 'Account',
        id: "0015400000GldOZAAZ",
        label: "navigate",
    }];
2
  • I have tried this but it is not working. Commented Aug 22, 2019 at 8:32
  • r u trying standalone app or any lightning experience page?
    – sdandamud1
    Commented Aug 22, 2019 at 14:31

You must log in to answer this question.

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