0

I am trying to build an API which under the hood will perform CRUD operations against the Salesforce API. I'm using the node-salesforce library for communication with Salesforce.

An example of creating a new Contact record:

  let newContact: SalesforceContact = {
    firstName: contact.firstName,
    lastName: contact.lastName,
    email: contact.email,
  }

  let response: any
  try {
    response = await sf.sobject('Contact').create(newContact)
  } catch (err) {...}

Which is fine, but when I try to do the same for Lead:

  let newLead: SalesforceLead = {
    name: lead.name,
    email: lead.email,
  }

  let response: any
  try {
    response = await sf.sobject('Lead').create(newLead)
  } catch (err) {...}

I get an 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."

Or when I try to pass {name, email} to the Account sobject, I get the same error for email. Once I remove it - I can create accounts.

So, apparently some of the fields in the object that I pass are wrong or non-existent. I am wondering if there is a place to find reference or documentation about the Salesforce API's schema.

I have tried searching stuff, but I mostly find examples of certain queries. And I need to have a full reference of the fields, so I have my options.

5 Answers 5

3

Lead's Name is a compound field and you cannot directly write values in Name field. Instead you will need to use the FirstName, LastName (same as you have with Contact).

The SOAP API documentation lists down the standard fields that is available for a particular SObject in Salesforce. You can additionally use the Object Management Settings for a particular SObject or Schema Builder to view these details within your Salesforce Org.

1
  • The SOAP API docs was exactly what I needed. Thanks! Mar 29, 2019 at 12:45
2

You can access the the Salesforce ORG agains which you are performing operations and can check under the Schema builder, where you will see something like this: enter image description here,

additionally, you can check the Object Reference for Salesforce and Lightning Platform

2

You can check the Schema Builder in Setup for available fields in your org (including custom fields), the Field Reference Guide for standard objects and fields, and other places as well.

0

If you don't have access to the objects directly in SFDC, perhaps this Force.com REST API sObject Resources should help you out: https://developer.salesforce.com/docs/api-explorer/sobject/Lead

0

The Object Manager and Schema Builder won't help you with many standard objects like FeedItem. Instead use the sfdx command line:

# Lists all objects
sfdx force:schema:sobject:list

# See the schema
sfdx force:schema:sobject:describe -s FeedItem

For more info run sfdx sfdx force:schema:sobject --help or read the docs.

You must log in to answer this question.

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