Dev: Get Object Name by ID

Published on February 10, 2026 DRTE


Get Object Name from ID (getObjectName)

1. 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.

When to use it:You are using a Polymorphic Lookup (like the WhatId on a Task or the TargetObjectID on a Process).You need to pass the "Object API Name" into other DRTE actions (like Generate Document Directly On Server) but only have the Record ID available.

2. Input & Output Interface

Input Parameters

ParameterData TypeRequiredDescription
Record IDsID (List)YesA list of 15 or 18-character Salesforce Record IDs.

Output Values

ParameterData TypeDescription
Object NamesText (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}.
Result: The document action now works dynamically for any object, with no hard-coded API names.

4. Developer Considerations

  1. No SOQL Required: This method does not perform any database queries. It is extremely "cheap" in terms of Salesforce Governor Limits and will not impact performance.
Null Handling: Ensure the ID passed is not null. Passing a null ID will result in a Flow error. We recommend adding a "Decision" element before this action to verify recordId is not null.
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.

Knowledge Article Number: KA-00118

View more articles in the knowledge base