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
Ash asmanAsh asman 

Iam Getting this Error

$A.getCallback() [tate is not defined] Callback failed: apex://createleaddata/ACTION$saveLead Failing descriptor: {c:createleaddatacmp}
In this vf page Geeting error but record is creating
public  class createleaddata{
    public static void saveLead (Lead ledrec) {
            //Insert Lead Record
            upsert ledrec;
        }catch(DmlException e) {
            //get DML exception message
            throw new AuraHandledException(e.getMessage());
        }catch(Exception e){
            //get exception message
            throw new AuraHandledException(e.getMessage());
        finally {

    createleadclick : function(component, event,helper) {
        //Getting the lead from page
        var newlec = component.get("v.newLead");
        //Assign server method to action variable
        var action = component.get("c.saveLead");
        //setting parameters for server method
            "ledrec": newlec
        action.setCallback(this, function(response) {
            //Getting the response state
            var state = response.getState();
            //check if response is success
            var resultToast = $A.get("e.force:showToast");
            if (tate === "SUCCESS") {
                resultToast.setParams({"title": "Success!",
                                      "message":"The record has been created successfully."
            else if(state=="ERROR"){
                var errors=response.getError();
                    if(errors[0]&& errors[0].message){
                        resultToast.setParams({"title":"Update Error",
                                               "message":"The update validation returned an error:"
                                               + errors[0].message
                } else{
                        "title":"Update Unknown Error",
                        "message":"The update returned an error:" +state
                    "title":"Update unknown Error",
                    "message": "The update returnde an error:" +state
            //This closes the Action Window
            var dismissActionPanel=$A.get("e.force:closeQuickAction");
        // Adding the action variable to the global action queue
Navin Selvaraj23Navin Selvaraj23
Hello Ash asman,

While you are comparing your state=="SUCCESS" in the if condition, there lies the error. Instead of "state" you have used "tate". That is the only spelling mistake.

PFB the highlighted line.
User-added image

Hope it helps. Please mark it as the best answer if this helps you.

Navin S