Skip to content

Instantly share code, notes, and snippets.

@melissajhansen
Last active January 16, 2018 16:54
Show Gist options
  • Save melissajhansen/942ddd0481ada0bc6990a9a5a2231197 to your computer and use it in GitHub Desktop.
Save melissajhansen/942ddd0481ada0bc6990a9a5a2231197 to your computer and use it in GitHub Desktop.
({
changeNameToSusie: function(cmp, event, helper) {
console.log("LDSErrorTest.handleRecordUpdated: entered");
var contact = cmp.get("v.contactRecord");
console.dir(contact);
contact.FirstName = "Susie";
cmp.set("v.contactRecord", contact);
cmp.find("recordLoader").saveRecord($A.getCallback(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
console.log("# Success" + cmp.find("recordLoader"));
cmp.find("recordLoader").reloadRecord();
}
else if (saveResult.state === "INCOMPLETE") {
console.log("User is offline, device doesn't support drafts.");
}
else if (saveResult.state === "ERROR") {
console.log('Problem saving record recordLoader, error: ' +
JSON.stringify(saveResult.error));
cmp.set("v.returnedError", JSON.stringify(saveResult.error));
}
else {
// this will fail with a message of My_Test_Formula__c: Unable to create/update fields: My_Test_Formula__c.
//Please check the security settings of this field and verify that it is
//read/write for your profile or permission set
console.log('Unknown problem, state: ' + saveResult.state +
', error: ' + JSON.stringify(saveResult.error));
cmp.set("v.returnedError", JSON.stringify(saveResult.error));
}
}));
console.log("LDSErrorTest.handleRecordUpdated: exit");
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment