I've been following the Salesforce documentation on using the force:recordData component to instantiate a new instance of a Case object (targetRecord) using component.getNewRecord, then pushing data into the targetFields object with the intent of ultimately saving a new Case record using component.saveRecord.

Issue: The record saves successfully, but only the Subject and Description are saved, the Issue_Type__c and Business_Is_Down__c fields are not being populated. They aren't even showing in the console.log when I convert simpleNewCase to a JSON string to review it.

I don't understand why these values aren't being stored/saved with the rest of the record, and the documentation doesn't make any special mention of handling custom fields differently.

Below is all of my code and the steps I've taken to get to this point

I created 3 attributes, same as the user guide:

<aura:attribute name="newCase" type="Object" />
<aura:attribute name="simpleNewCase" type="Object" />
<aura:attribute name="newCaseError" type="String" />

I put the recordData component in my .cmp:

<force:recordData aura:id="caseRecordCreator" 
                      targetError="{!v.newCaseError}" />

I instantiate the new object during my init actions:

init: function (component, event, helper) {
        "Case", // sObject type (objectApiName)
        null,      // recordTypeId
        false,     // skip cache?
        $A.getCallback(function() {
            var rec = component.get("v.newCase");
            var error = component.get("v.newCaseError");
            if(error || (rec === null)) {
                console.log("Error initializing record template: " + error);
            console.log("Record template initialized: " + rec.apiName);

I then set some values on the simpleNewCase attribute based on data from the page and invoke saveRecord on the object:

save: function (component, event, helper) {
    console.log('Invoke Save On Click');
    var subject = component.get("v.subjectVal");
    var description = component.get("v.descriptionVal");
    var platform = component.get("v.platformVal");
    var systemDown = component.get("v.systemDownVal");
    console.log('Save on Click - Subject: ' + subject + ' | Description: ' + description + ' | Platform: ' + platform + ' | System Down: ' + systemDown);

    component.set("v.simpleNewCase.Subject", subject);
    component.set("v.simpleNewCase.Description", description);
    component.set("v.simpleNewCase.Issue_Type__c", platform);
    component.set("v.simpleNewCase.Business_Is_Down__c", systemDown);
    console.log('Record: ' + JSON.stringify(component.get("v.simpleNewCase")));

    component.find("caseRecordCreator").saveRecord(function(saveResult) {
        if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
            // record is saved successfully
            var resultsToast = $A.get("e.force:showToast");
                "title": "Saved",
                "message": "The record was saved."
        } else if (saveResult.state === "INCOMPLETE") {
            // handle the incomplete state
            console.log("User is offline, device doesn't support drafts.");
        } else if (saveResult.state === "ERROR") {
            // handle the error state
            console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
        } else {
            console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));

This is the output I get in my console:

Save on Click - Subject: Test Subject | Description: Test Description | Platform: Platform A | System Down: No

Record: {"Contact":null,"ContactId":null,"Description":"Test Description","Owner":{"Id":"REDACTED","Name":"Morgan Marchese"},"OwnerId":"REDACTED","RecordType":{"Id":"REDACTED","Name":"Customer Community Site"},"RecordTypeId":"REDACTED","Status":"New","Subject":"Test Subject","LastModifiedDate":null,"SystemModstamp":null,"CreatedDate":null,"ContactEmail":null,"ClosedDate":null,"Id":null}

  • 1
    What is the FLS on your custom fields? Have you verified from that aspect if that's causing any issues?
    – Jayant Das
    Oct 23, 2018 at 15:41
  • They did not have access to read or edit these fields, adding access to read/edit has fixed it so thank you for that - but I don't like the idea of giving them full edit access to these fields. Giving Read-Only access results in the field showing up in the JSON string with the right value, but the value is not saved during record save (understandably). Is there any way within a Lightning Component to set the Sharing access to without sharing? Or will I need to pass the created component/object to a custom save method in the handler? Oct 23, 2018 at 16:09
  • The FLS depends on your requirements. If you want someone to edit a value on a field, you definitely need the edit access. If not, then either hide or read only depending on your use cases. I will not recommend without sharing unless and until really required. Because LDS honors the FLS, if at all you want to "override" the behavior, you need to go a custom route.
    – Jayant Das
    Oct 23, 2018 at 16:14
  • Typically my company uses without sharing on controllers where the result of that controller should always be the same, irrespective of the user and/or their permissions. The risk is understood, In this case I think we can get by by allowing them to read/write the field but changing their overall CRUD so that they can't update/edit. If you want to make your comment about FLS into an answer I'll mark it best. Oct 23, 2018 at 17:50
  • I get your point. Have though rolled up the comments as an answer.
    – Jayant Das
    Oct 23, 2018 at 18:02

1 Answer 1


Rolling up comments as an answer for resolution of this question.

What is the FLS on your custom fields? Have you verified from that aspect if that's causing any issues?

They did not have access to read or edit these fields, adding access to read/edit has fixed it

The issue here turned out to be the FLS on the custom fields where the User using the component did not have any access on the custom fields. Providing right level of access resolved the issue here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .