You need to sign in to do that
Don't have an account?
Cannot read property 'get' of undefined. May i know if there are any trouble shooting points
Cannot read property 'get' of undefined. May i know if there are any trouble shooting points.
I have mentioned everything correct, but still i am facing the issue, may i know if there are any trouble shooting points.
Code:
Component:
<lightning:combobox name="Select Instance:" aura:id="selctOrg" placeholder="Select an Option" options="{! v.orgList }" value="{!v.selectedOrg }" onchange="{! c.handleChange }"/>
js controller:
var selectedSOrg = component.find("selctOrg").get("v.value");
Error is: [Cannot read property 'get' of undefined]
Below is the code that i had in my controller and helper.
controller:
({ doinit : function(component, event, helper) { helper.fetchSBHelper(component, event, helper); } })
Helper:
({ fetchSBHelper : function(component, event, helper) {
var sOrg = component.find("selctOrg"); var selectedSOrg = sOrg.get("v.value"); alert("selectedSOrg"+selectedSOrg);
} })
I have mentioned everything correct, but still i am facing the issue, may i know if there are any trouble shooting points.
Code:
Component:
<lightning:combobox name="Select Instance:" aura:id="selctOrg" placeholder="Select an Option" options="{! v.orgList }" value="{!v.selectedOrg }" onchange="{! c.handleChange }"/>
js controller:
var selectedSOrg = component.find("selctOrg").get("v.value");
Error is: [Cannot read property 'get' of undefined]
Below is the code that i had in my controller and helper.
controller:
({ doinit : function(component, event, helper) { helper.fetchSBHelper(component, event, helper); } })
Helper:
({ fetchSBHelper : function(component, event, helper) {
var sOrg = component.find("selctOrg"); var selectedSOrg = sOrg.get("v.value"); alert("selectedSOrg"+selectedSOrg);
} })
In Init event, combobox has not been rendered when you call component.find("selectedSOrg"), it returns undefined.
Consequently, in this line: var selectedSOrg = sOrg.get("v.value"), the code is trying to get value from an undefined object, that is why it throws exception.
If you put the same code in handleChange js function, it will succeeed.
All Answers
Sample Code:
var contractNo = component.find("contractNo");
var contractNoValue = contractNo.get("v.value")
In the above code, there should be a component with id "contractNo", else we will get this error.
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
I have added the aura:id="selctOrg" in the combobox and added the same in the js controller.
Is it the same you are telling?
https://salesforce.stackexchange.com/questions/194804/lightning-component-cannot-read-property-get-of-undefined
In Init event, combobox has not been rendered when you call component.find("selectedSOrg"), it returns undefined.
Consequently, in this line: var selectedSOrg = sOrg.get("v.value"), the code is trying to get value from an undefined object, that is why it throws exception.
If you put the same code in handleChange js function, it will succeeed.
www.genera.cl