You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Error in $A.getCallback() [quickcon is not defined]
I am facing "Error in $A.getCallback() [quickcon is not defined]" and not able to find whats the issue, can anyone help?
Component
Controller
Apex method
Many Thanks for your help
Component
<aura:component implements="force:appHostable,force:hassObjectName,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="RatingVsAccount"> <aura:attribute name="cons" type="Contact" /> <aura:registerEvent name="quickcontact" type="c:QuickContactEvent"></aura:registerEvent> <aura:attribute name="newContact" type="Contact" default="{'sobjectType': 'Contact', 'FirstName':'', 'LastName':'', 'Email':'', 'Phone':'' }"/> <div class="slds-col-grid"> <lightning:input aura:id="fieldId" required="true" label="Last Name" name="filename" type="text" message-when-value-missing="This field is mandatory" value="{!v.newContact.LastName}"/> <lightning:button label="save" onclick="{!c.savecontact}"/> </div> </aura:component>
Controller
({ savecontact : function(component, event, helper) { var action = component.get("c.save"); var con = component.get("v.newContact"); action.setParams({ con : con, Accid : component.get('v.AccountId'), }); action.setCallback(this, function(a) { var state = a.getState(); if (state === "SUCCESS") { var name = a.getReturnValue(); var CompEvent = component.getEvent('quickcontact'); CompEvent.setParams({ quickcon, name}); CompEvent.fire(); } }); $A.enqueueAction(action) }, })
Apex method
@AuraEnabled public static Contact save(contact con, string Accid) { con.AccountId = Accid; insert con; system.debug('>>> con' + con); return con; }Event
<aura:event type="COMPONENT" description="Event template" > <aura:attribute name="quickcon" type="Contact"></aura:attribute> </aura:event>
Many Thanks for your help
Greetings to you!
There is a typo in JS controller on this line: CompEvent.setParams({ quickcon, name});
You need to set the params like below:
CompEvent.setParams({ quickcon : name});
Use below controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
There is a typo in JS controller on this line: CompEvent.setParams({ quickcon, name});
You need to set the params like below:
CompEvent.setParams({ quickcon : name});
Use below controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas