0

A customer installed our managed package, which makes an API call to Salesforce, sending basic contact information from the web platform and attempts to create a SObject record in Salesforce based on their preferences (defaults to creating a Lead or Contact, but they can select creating a Case, Account or any Custom Object).

Leads and Contacts are being created successfully, but when they attempt to start creating "Account" records, they're hitting the following error:

INVALID_FIELD_FOR_INSERT_UPDATE: Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

They have a System Admin user doing all the integrations, and we've checked all the settings we could think of:

  • All FLS settings on Account & Contact

  • Default Account available record type is set to Person Account for the System Admin

  • Validation rules, etc

What could be the issue? I believe the integration is just populating the Account.Name field with the first/last name of the contact, but I feel like there's a special quark with Person Accounts that we're missing.

1 Answer 1

4

You can't use Name if you're creating a Person Account (it behaves as a read-only compound field). Set the individual name fields correctly. Here's an example that works in my org in Workbench:

URL:

POST /services/data/v47.0/sobjects/Account

Body:

{ "FirstName": "Brian", "LastName": "Fear", "RecordType": { "Name": "Person Account" } }
9
  • "RecordType": { "Name": "Person Account" } will actually work with any SF org with person accounts? Or maybe using the DeveloperName => Person_Account? Commented Apr 23, 2020 at 19:53
  • Could we get by without setting RecordType or will we get an error trying to write to FirstName and LastName? Let's assume we had a setting or knew beforehand that the org definitely uses Person Accounts Commented Apr 23, 2020 at 19:54
  • 1
    @BrianMiller Ironically, DeveloperName does not work (you get a "not an External ID field" error), and the name itself will only work if it is globally unqiue. Otherwise, you end up having to do a query to get the ID if you don't already have it.
    – sfdcfox
    Commented Apr 23, 2020 at 19:55
  • 1
    @BrianMiller I'm pretty sure that if RecordTypeId is omitted, and the Person Account type is the default, you wouldn't need to include it in the payload. I'd have to test that out.
    – sfdcfox
    Commented Apr 23, 2020 at 19:56
  • 1
    @BrianMiller Just confirmed it. It does work.
    – sfdcfox
    Commented Apr 23, 2020 at 19:59

You must log in to answer this question.

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