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
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