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?

0

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

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

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.