API Names in Salesforce

 In Salesforce, an API Name is a unique identifier for metadata components like fields, objects, or custom settings that enables external systems, scripts, and integrations to reference Salesforce data programmatically. The API name remains consistent, even if the label displayed in the user interface changes, making it essential for maintaining integration stability.

Key Characteristics of API Names

  1. Field and Object API Names:

    • Standard object and field API names generally mirror their label names, but with spaces removed.
    • Custom fields and objects have the suffix __c, denoting them as custom.
      • Example: A custom object called "Project" would have an API name of Project__c.
      • A custom field called "Start Date" on the Project object would have an API name of Start_Date__c.
  2. Case-Sensitivity:

    • API names in Salesforce are case-sensitive, so it’s essential to match them exactly when using them in code or integrations.
  3. Usage:

    • API names are used in SOQL queries, Apex code, integration tools (like REST/SOAP APIs), custom formulas, reports, and any other context where data needs to be programmatically accessed.
  4. Examples of Common API Names:

    • Standard Field: Account.Name (for the Name field on the Account object)
    • Custom Field: Project__c.Start_Date__c
    • Standard Object: Contact, Opportunity
    • Custom Object: Project__c, Expense__c

 Example Usage in SOQL

If you wanted to query a custom field Start_Date__c on a custom object Project__c, your SOQL query would look like this:

SELECT Name, Start_Date__c FROM Project__c WHERE Status__c = 'Active'

Knowing the correct API names is essential for ensuring your SOQL queries, Apex code, and integrations work accurately in Salesforce. Let me know if you’d like to see more examples with API names in specific contexts!

Comments

Popular posts from this blog

18 - LWC - BEST PRACTICES - For accessing HTML elements and their values in JavaScript

6 - Object Relationships (Lookup and Master-Detail and Junction Objects)