You need to sign in to do that
Don't have an account?
Michael M
Lightning component saves records in sandbox, but has error in production
Hello, I am using a lightning component to create new records. In sandbox it works fine, but in Production, when I click save, it is giving an error response. When I print the error message, it just says "undefined". Any idea what the issue could be?
Your ask seems similar to
https://salesforce.stackexchange.com/questions/173846/lightning-component-works-on-sandbox-but-not-on-production . Can you check if your scenario is the same? Can you share more details around what your lightning component does so the community can suggest better?
All Answers
Your ask seems similar to
https://salesforce.stackexchange.com/questions/173846/lightning-component-works-on-sandbox-but-not-on-production . Can you check if your scenario is the same? Can you share more details around what your lightning component does so the community can suggest better?
So I am using my component to replace the "new" button when creating a new record (for a custom object called "Community_lead__c"). For 2 of the record types, I am displaying a custom layout (with my component). When trying to save the record, it works fine in sandbox, but in production it is throwing error. Below are my component and controller:
Here is the snippet from my component JS controller to save the record. I am running into the bold line, but for the error message it just says "undefined":
saveRecord : function(component, event, helper) {
if (component.find('otherSource').get("v.value") != "empty"){
component.set("v.propertyRecord.Name", component.find('propName').get("v.value"));
component.set("v.propertyRecord.Email__c",component.find('propBaths').get("v.value") );
component.set("v.propertyRecord.Phone__c", component.find('propPrice').get("v.value") );
component.set("v.propertyRecord.Referral_Source__c", component.find("propStatus").get("v.value"));
component.set("v.propertyRecord.Address__c", component.find('Street').get("v.value") );
component.set("v.propertyRecord.City__c", component.find('City').get("v.value") );
component.set("v.propertyRecord.State__c", component.find('State').get("v.value") );
component.set("v.propertyRecord.Zip__c", component.find('Zip').get("v.value") );
component.set("v.propertyRecord.Country__c", component.find('Country').get("v.value") );
component.set("v.propertyRecord.Other_Referral_Source__c", component.find('otherSource').get("v.value") );
component.set("v.propertyRecord.Responsible_Party__c", component.find('RP').get("v.value") );
component.set("v.propertyRecord.Responsible_Party_Phone__c", component.find('RPP').get("v.value") );
component.set("v.propertyRecord.Responsible_Party_Email__c", component.find('RPE').get("v.value") );
component.set("v.propertyRecord.Services_Needed__c", component.find('ServicesNeed').get("v.value") );
component.set("v.propertyRecord.Note__c", component.find('Note').get("v.value") );
component.set("v.propertyRecord.Status__c", component.find('Status').get("v.value") );
component.set("v.propertyRecord.Lead_initiated_by__c", component.find('InitiatedBy').get("v.value") );
}
//Alp fields:
if (component.find('otherSource').get("v.value") == "empty"){
component.set("v.propertyRecord.Name", component.find('alpInquirer').get("v.value"));
if (component.find('propBaths').get("v.value") != null){
component.set("v.propertyRecord.Email__c",component.find('propBaths').get("v.value") );}
component.set("v.propertyRecord.Phone__c", component.find('propPrice').get("v.value") );
if (component.find('Street').get("v.value") != null){
component.set("v.propertyRecord.Address__c", component.find('Street').get("v.value") );
component.set("v.propertyRecord.City__c", component.find('City').get("v.value") );
component.set("v.propertyRecord.State__c", component.find('State').get("v.value") );
component.set("v.propertyRecord.Zip__c", component.find('Zip').get("v.value") );
component.set("v.propertyRecord.Country__c", component.find('Country').get("v.value") );}
if (component.find('alpInquirer').get("v.value") != null){
component.set("v.propertyRecord.Inquirer__c", component.find('alpInquirer').get("v.value") );}
if (component.find('alpRelationship').get("v.value") != null){
component.set("v.propertyRecord.Relationship__c", component.find('alpRelationship').get("v.value") );}
if (component.find('alpAge').get("v.value") != null){
component.set("v.propertyRecord.Age__c", component.find('alpAge').get("v.value") );}
if (component.find('Dob').get("v.value") != null){
component.set("v.propertyRecord.DOB__c", component.find('Dob').get("v.value") );}
if (component.find('alpPrompted').get("v.value") != null){
component.set("v.propertyRecord.What_prompted_your_call_today__c", component.find('alpPrompted').get("v.value") );}
if (component.find('alpConcern').get("v.value") != null){
component.set("v.propertyRecord.What_s_your_biggest_concern_right_now__c", component.find('alpConcern').get("v.value") );}
if (component.find('alpImpacting').get("v.value") != null){
component.set("v.propertyRecord.How_is_this_impacting_you__c", component.find('alpImpacting').get("v.value") );}
if (component.find('alpCurrentResidence').get("v.value") != null){
component.set("v.propertyRecord.Where_does_your_currently_live__c", component.find('alpCurrentResidence').get("v.value") );}
if (component.find('alpAwareness').get("v.value") != null){
component.set("v.propertyRecord.Is_he_she_aware_you_re_looking_for_place__c", component.find('alpAwareness').get("v.value") );}
if (component.find('alpFeeling').get("v.value") != null){
component.set("v.propertyRecord.How_does_he_she_feel_about_moving__c", component.find('alpFeeling').get("v.value") );}
if (component.find('alpFamilyFriends').get("v.value") != null){
component.set("v.propertyRecord.Are_there_family_friends_helping_decide__c", component.find('alpFamilyFriends').get("v.value") );}
if (component.find('alpMostImportant').get("v.value") != null){
component.set("v.propertyRecord.What_s_most_important_in_community__c", component.find('alpMostImportant').get("v.value") );}
if (component.find('alpMostImportant2').get("v.value") != null){
component.set("v.propertyRecord.What_do_you_think_is_most_impt_to_your__c", component.find('alpMostImportant2').get("v.value") );}
if (component.find('alpRoutine').get("v.value") != null){
component.set("v.propertyRecord.Walk_me_through_your_daily_routine__c", component.find('alpRoutine').get("v.value") );}
if (component.find('alpHobbies').get("v.value") != null){
component.set("v.propertyRecord.What_does_he_she_enjoy_doing_hobbies__c", component.find('alpHobbies').get("v.value") );}
if (component.find('alpOneThing').get("v.value") != null){
component.set("v.propertyRecord.If_I_could_do_one_thing_to_help_you__c", component.find('alpOneThing').get("v.value") );}
if ( component.find('alpNextStep').get("v.value") != null){
component.set("v.propertyRecord.The_next_step_is__c", component.find('alpNextStep').get("v.value") ); }
if (component.find('alpContactMethod').get("v.value") != null){
component.set("v.propertyRecord.What_is_best_way_to_contact_you__c", component.find('alpContactMethod').get("v.value") );}
if (component.find('alpHowdYouHear').get("v.value") != null){
component.set("v.propertyRecord.May_I_ask_how_you_heard_of_us__c", component.find('alpHowdYouHear').get("v.value") );}
if (component.find('alpAnyoneElse').get("v.value") != null){
component.set("v.propertyRecord.Is_there_anyone_else_I_should_contact__c", component.find('alpAnyoneElse').get("v.value") );}
if (component.find('Status').get("v.value") != null){
component.set("v.propertyRecord.Status__c", component.find('Status').get("v.value") );}
if (component.find('nextStepNotes').get("v.value") != null){
component.set("v.propertyRecord.Next_step_notes__c", component.find('nextStepNotes').get("v.value") );
}
component.set("v.propertyRecord.Name", component.find('propName').get("v.value"));
if (component.find('contactedNotes').get("v.value") != null){
component.set("v.propertyRecord.Contacted_notes__c", component.find('contactedNotes').get("v.value") );
}
}
var tempRec = component.find("forceRecord");
tempRec.saveRecord($A.getCallback(function(result) {
console.log(result.state);
var resultsToast = $A.get("e.force:showToast");
if (result.state === "SUCCESS") {
resultsToast.setParams({
"title": "Saved",
"message": "The record was saved."
});
resultsToast.fire();
var recId = result.recordId;
helper.navigateTo(component, recId);
} else if (result.state === "ERROR") {
console.log('Error: ' + JSON.stringify(result.error));
resultsToast.setParams({
"title": "Error",
"message": result.error + " There was an error saving the record: " + JSON.stringify(result.errormessage)
});
resultsToast.fire();
} else {
console.log('Unknown problem, state: ' + result.state + ', error: ' + JSON.stringify(result.error));
}
}));
},