+ Start a Discussion
Ravi KumAR 1060Ravi KumAR 1060 

Error!!!!!!

In HELPER

({
    helperMethodAgent : function(Component) {
        
        //for logs
        console.log('in create record function');
        
        //getting the candidate information
        var varAgent = component.get("v.AttrAgent");
        
        //Calling the APEX Function
        var action = component.get("c.CreateAgent");
        
        //setting the Apex Prameter
        action.setParams({
            Agent:varAgent
        });
        // setting the callback
        action.setCallback(this,function(response){
       
            //get the response state
            var state =response.getState();
            
       //check if result is successfull
            if(state=="SUCCESS") {
                //Reset Form
                var NewEmptyAgentRec = {'sobjectType':'Agent__c',
                          'Agent_Name__c': '',
                          'D_O_B__c' : '',
                          'Gender__c': '',
                          'Mobile_Number__c': '',
                          'Email__c' : '',
                          'Registration_Date__c': '',
                          'Address__c': '',
                          };
                //resetting the value in the form
                component.set("v.AttrAgent",NewEmptyAgentRec);
                alert('Record is Successfully Created');
              
    }
            else if(state="Error"){
                alert('error in calling Server side action');
           //error details
           var ErrorDetails = response.getError();
           alert('Reason of error = '+ErrorDetails[0].message)
            }
});
        //adds the server-side action to the queue
        $A.enqueueAction(action);
    }
});

Getting this error while saving
FIELD INTEGRITY EXCEPTION
Failed to save InsuranceAppRecordHelper.js: Expected ':', found 'STRING' [1, 13]: Source

Help me with this Code
Santosh Kumar 348Santosh Kumar 348
Hi Ravi.

I can see few error in your code.
  • You have added semicolon  at the end, which is not required. Remove the semicolon.
//adds the server-side action to the queue
        $A.enqueueAction(action);
    }
});
  • On the very first line you have used "helperMethodAgent : function(Component)" but in code you have used "var action = component.get("c.CreateAgent");" Lightning is case sensitive so "Component" and "component" won't be treated same an you will get error. So follow the same case and make the changes accordingly.
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful.

Regards,
Santosh Kumar