+ Start a Discussion
Thiago Barbosa 1Thiago Barbosa 1 

lightning:inputField console.log is undefinied

selectStageName : function(component, event, helper){
         var stageName = component.find("stgName").get("v.value");
         console.log("Stage Name" + stageName);
    },
 
<lightning:inputField aura:id="stgName" fieldName="StageName" value="{!v.opportunity.StageName}" onchange="{!c.selectStageName}" />

 
Narender Singh(Nads)Narender Singh(Nads)
Hi Thiago,
The reason you are getting is because 'v.opportunity.StageName' is undefined in your component.
If you are using: <aura:attribute name="opportunity" type="Opportunity"/> 
then, please define default StageName in default attribute.

If you are using lightning:recordeditform then use:
<lightning:inputField aura:id="stgName" fieldName="StageName" onchange="{!c.selectStageName}" />
(Don't use value attribute. Value attribute is used to override the present record value.)

Let me know if it helps.
Thanks