You need to sign in to do that
Don't have an account?
VSK98
Getting Error in $A.getCallback() [Cannot read property 'Name' of null] Failing descriptor: {lightning:input}
Hello All,
I have just tried my first lightning page, the page contains two text fields and one button. Once click on button account record should be create. After click on preview i can able to see the form but when i entered the data in the text box i am getting below error. Could you please help me on this.
Please find the lightning code below:
Advance thanks,
VSK98
I have just tried my first lightning page, the page contains two text fields and one button. Once click on button account record should be create. After click on preview i can able to see the form but when i entered the data in the text box i am getting below error. Could you please help me on this.
Please find the lightning code below:
<aura:component > <aura:attribute name="NewAccount" type="Account"/> <lightning:input label="AccountName" name="myname" required="true" value="{!v.NewAccount.Name}" /> <lightning:input label="Fax" name="fax" required="true" value="{!v.NewAccount.fax}"/> <lightning:button variant="brand" label="Submit" onclick="{!c.createAccount}"/> </aura:component> ({ myAction : function(component, event) { var newAcc = component.get("v.NewAccount"); var action = component.get("c.createAccount"); action.setParams({ "acc": newAcc }); action.setCallback(this, function(a) { var state = a.getState(); if (state === "SUCCESS") { var name = a.getReturnValue(); alert("hello from here"+name); } }); $A.enqueueAction(action) } })
Advance thanks,
VSK98
As per Gauravendra it is right you are calling wrong controller action.
But problem [Cannot read property 'Name' of null] which shows in pop while you type in input box is due to required lightning:input to overcome this issue you need to set default values of NewAccount Attribute.
also am sharing working code of yours which I tried in my dev org
Let me know , Is it work?
All Answers
From component button onclick it should call the javascript handler. You are directly calling the apex method.
Change the onclick to call myAction method of javascript. And add semicolon after $A.enqueueAction(action);
Let me know, if this all it needed.
Hope this helps.
As per Gauravendra it is right you are calling wrong controller action.
But problem [Cannot read property 'Name' of null] which shows in pop while you type in input box is due to required lightning:input to overcome this issue you need to set default values of NewAccount Attribute.
also am sharing working code of yours which I tried in my dev org
Let me know , Is it work?
Thanks for your response!
I have tried with your code but i am getting another issue. please find the error below.
Regards,
Siva
It's working fine on my side.
Please share your code Am curious to know what you missing.
Really strange to me!!!!!
Please find the snippet below:
Component:
Client Side Controller:
Application:
Server Side Controller:
Adv Thanks,
VSK98
you are facing the issue due to the same name of JS Action As createAccount and Apex Method as createAccount
while we take same name of JS action and Apex Method it's lightning behavior of recurrsive call.
Change JS action name
Same in JS controller Too
Keep All code same Just change JS action, Your Code will work perfectly.
I had simillar issue, I have added the aura class access to user profile or you can add it in permission set to resolve issue
https://releasenotes.docs.salesforce.com/en-us/winter21/release-notes/salesforce_release_notes.htm#:~:text=Home%20%3E-,Salesforce%20Winter%20'21%20Release%20Notes,to%20your%20customers%2C%20from%20anywhere.&text=Our%20release%20notes%20offer%20brief,of%20enhancements%20and%20new%20features (https://apc01.safelinks.protection.outlook.com/?url=https:%2F%2Freleasenotes.docs.salesforce.com%2Fen-us%2Fwinter21%2Frelease-notes%2Fsalesforce_release_notes.htm%23:~:text%3DHome%2520%253E-%2CSalesforce%2520Winter%2520'21%2520Release%2520Notes%2Cto%2520your%2520customers%252C%2520from%2520anywhere.%26text%3DOur%2520release%2520notes%2520offer%2520brief%2Cof%2520enhancements%2520and%2520new%2520features&data=02%7C01%7CRadhashree_Yarashi%40infosys.com%7C847dd6b5ba334cb9f3b008d8639306de%7C63ce7d592f3e42cda8ccbe764cff5eb6%7C1%7C0%7C637368830407597564&sdata=qe5nCgUKHjh3P9leH3E5ZOCiV4MN1BoH1C7Jp8xHf3w%3D&reserved=0" style="color:#0563c1; text-decoration:underline)
https://admin.salesforce.com/blog/2020/critical-update-ensure-users-have-access-to-auraenabled-methods (https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fadmin.salesforce.com%2Fblog%2F2020%2Fcritical-update-ensure-users-have-access-to-auraenabled-methods&data=02%7C01%7CRadhashree_Yarashi%40infosys.com%7C847dd6b5ba334cb9f3b008d8639306de%7C63ce7d592f3e42cda8ccbe764cff5eb6%7C1%7C0%7C637368830407597564&sdata=0SDoj3elDJtlT9LZMxTXy%2FE24JRmi90JLEFQ207V4WI%3D&reserved=0" style="color:#0563c1; text-decoration:underline)
Newest Chrome Version: 96.0.4664.45
Here our Message:
Error in $A.getCallback() [Cannot read properties of undefined (reading 'set')]
Object._resetContentBodyAndFooter()@https://xxxx.lightning.force.com/components/flowruntime/flowRuntimeV2.js:27:277
Object.buildComponentTree()@https://xxxx.lightning.force.com/components/flowruntime/flowRuntimeV2.js:17:19
eval()@https://xxxxx.lightning.force.com/components/flowruntime/runtimeLib.js:1:24868
Object.eval()@https://xxxx.lightning.force.com/components/flowruntime/flowRuntimeV2.js:11:77
Q._updateState()@https://xxxxx.lightning.force.com/components/flowruntime/runtimeLib.js:1:26471
eval()@https://xxxxx.lightning.force.com/components/flowruntime/runtimeLib.js:1:26847