Skip to main content
Nintex Community Menu Bar
Question

Is there a way to determine which object an Id belongs to?

  • July 9, 2024
  • 11 replies
  • 135 views

Forum|alt.badge.img+20

Is there a way to determine which object an Id belongs to?

11 replies

Forum|alt.badge.img+17
  • Nintex Employee
  • 3766 replies
  • July 9, 2024

The object prefix is the first three characters of the object ID.  Take those three characters and create a URL like this: 

https://[instance].salesforce.com/[object prefix]/o

You should get an overview page for the object. 


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

Is there an object of these three characters anywhere?


Forum|alt.badge.img+8
  • 649 replies
  • July 9, 2024

You can… kindof.  The first three characters of an id are its keyprefix.  Skuid models have a property of keyprefix and objectName, so if you have a model on the page, you can figure out the object from an id.


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

I’m not sure I follow. Are you saying to create a model via javascript using the keyprefix and then I’ll have the object in question?


Forum|alt.badge.img+8
  • 649 replies
  • July 9, 2024

No, I don’t know of a way to to an arbitrary lookup for the keyprefix.  But for instance if you know that your id will either be an account or a contact, you can put an account model and a contact model on your page and get that info there.  If you really need arbitrary lookup, you may need to write some Apex.


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

Looking for any object. There is a way via Apex, but I’m not sure I’d like to make a server call to get this information. I want this to be an instant response thing.


Forum|alt.badge.img+8
  • 649 replies
  • July 9, 2024

Yeah, I don’t know of a way to do this in Javascript land.


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

I was thinking of creating one gigantic object variable in order to do this in javascript using this list. I would only have to manage adding the custom objects in the org.

https://help.salesforce.com/apex/HTViewSolution?id=000005995&language=en_US

What do you think? As a javascript object I figure it would be practically instant to determine the object for the id using this method.


Forum|alt.badge.img+8
  • 649 replies
  • July 9, 2024

Yeah, that would work as long as you don’t mind keeping up with that list.


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

It would only be in one that I would manage it. Static Resource javascript. Starting to really enjoy Sublime Text 3 w/ Mavensmate.


Forum|alt.badge.img+11

Here’s a simple example if you need something to get started with:

function EntityPrefixDecoder(recordID) {<br>&nbsp; &nbsp; var prefixEntityMap = {<br>&nbsp; &nbsp; &nbsp; &nbsp; '001': 'ACCOUNT',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '002': 'NOTE',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '003': 'CONTACT'<br>&nbsp; &nbsp; };<br>&nbsp; &nbsp; if (recordID === null || (recordID.length !== 15 &amp;&amp; recordID.length !== 18)) {<br>&nbsp; &nbsp; &nbsp; &nbsp; return null;<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return prefixEntityMap[recordID.slice(0, 3)];<br>}<br>var id = '00290000000jPatPAT';<br>console.log(EntityPrefixDecoder(id));