Dev: Get Object Name by ID

Functional Summary

In Salesforce, every Record ID begins with a three-character prefix that identifies its Object Type (e.g., 001 for Account, 500 for Case). The getObjectName (Get Object Name from ID) method programmatically inspects a provided Record ID and returns the corresponding API Name of that object.

This is particularly useful when:



2. Input & Output Interface

Input Parameters

Parameter

Data Type

Required

Description

Record IDs

ID (List)

Yes

A list of 15 or 18-character Salesforce Record IDs.


Output Values

Parameter

Data Type

Description

Object Names

Text (List)

The API Name of the object (e.g., Opportunity, pscdnyrichtext__ESignature_Log__c).







3. Implementation in Flow Builder

Scenario: Dynamic Document Generation

Imagine a Flow that allows a user to generate a document from several different objects (Account, Opportunity, and Quote). The Generate Document Directly on Server action requires an "Object API Name" input.

Step 1: Get the Object Name

  1. Add an Action element.
  2. Search for "Get Object Name from ID".
  3. Set the recordIds to your current record's ID (e.g., {!recordId}).
  4. Store the output in a variable called varObjectApiName.

Step 2: Use the Output

  1. Add the "Generate Document Directly On Server" action.
  2. In the Object API Name field, simply pass the variable {!varObjectApiName}.


4. Developer Considerations

API Name vs. Label: Always remember this returns the API Name (e.g., Custom_Object__c) and not the UI Label (e.g., Custom Object). DRTE actions always require the API Name.

Redirecting you to the article... Click here if you are not redirected automatically.