0

I'm passing the following input to the built-in updateRecord function of LWC:

[{"fields":{"BirthDate":"1947-02-19","Id":"0035w000036mj7YAAQ"}}]

But I'm getting an error during updateRecord:

Field BirthDate does not exist.

I'm simply trying to update the BirthDate on a single contact. Other fields do not give the error, such as Phone:

[{"fields":{"Phone":"(512) 757-6009","Id":"0035w000036mj7YAAQ"}}]

I even tried using a custom Date field called Test_Date__c and it worked fine:

[{"fields":{"Test_Date__c":"2023-04-26","Id":"0035w000036mj7fAAA"}}]

What could be causing the error?

2
  • Have you checked FLS?
    – Nick C
    Apr 14 at 0:25
  • @NickCook yep, FLS looks good. What's interesting is I created a custom field called Test_Date__c and no errors when updating that field.
    – snippet69
    Apr 14 at 0:56

1 Answer 1

2

The issue is being caused by the difference in case between the field name you're passing. This should be 'Birthdate' not 'BirthDate'.

Interestingly, this case sensitivity isn't an issue if you import the field names using '@salesforce/schema' notation. Best practice is to use this, so I'd recommend importing your field references like this:

import BIRTHDATE_FIELD from '@salesforce/schema/Contact.Birthdate';

Reading the documentation this helps to catch typos, and also ensures that the platform recognizes your component's dependency on the referenced fields and also ensures that code works when object and field names change.

Reference:

Import Objects and Field from @salesforce/schema

You must log in to answer this question.

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