function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
degmodegmo 

Get name of custom object by ID

Hello,
I am troubleshooting an issue where permissions where removed/edited by an automated process.  I exported the logs from "view setup audit trail".  I found a bunch of entries like this 
Removed the ModifyAllRecords on 01I6A000001icPZ object permission from Profile 00e6A000000vIEC
 

I have two questions that I am hoping someone can help me with.

Question #1
To identify the object that was impacted, I wrote the follwoing code 

Id someId = '01I6A000001icPZ';
System.debug(someId.getSObjectType());
System.debug(someId.getSObjectType().getDescribe().getName());
Both of these return "CustomEntityDefinition" and not the actual object name.  Am I missing something?

Question #2
To get the profile name, I wrote the following query
Select name from profile where id = '00e6A000000vIEC'
The profile name i get back isn't in the list of profiles that are avialble in the UI.  I made sure to select "all" so I know I am looking at the list of all available profiles.  Is it possible for the profile to be deleted and but the SOQL would still return it back?
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Degmo,

As mentioned in this help article as well https://help.salesforce.com/articleView?id=000340200&language=en_US&type=1&mode=1 the response you are getting is the correct value could you please check once in the setup and also are you the system admin? 

Looking forward to your response.

Regards,
Anutej 
ShirishaShirisha (Salesforce Developers) 
HI,

Greetings!

As mentioned in the article the below line should display the name of othe Object based on the record Id:
 
Id sampleid = '00561000000Mjya'; System.debug('object is '+ sampleid.getsobjecttype());
Reference:https://help.salesforce.com/articleView?id=000340200&language=en_US&type=1&mode=1

Also,the SOQL query to return the Profile name is perfect and working fine for me.Please double check,if you have API name different.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
 
degmodegmo
Hi Shirisha & Anutej,
I am trying to pull this by object ID and not record ID.  Using the code below where the Id is the object ID of a custom object, the response I get is "CustomEntitiyDefinition".  I was expecting it to return the name of the custom object.
Id sampleid = '00561000000Mjya'; System.debug('object is '+ sampleid.getsobjecttype());