Is there a way to determine which object an Id belongs to?
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/oobject prefix]/o
You should get an overview page for the object.
Is there an object of these three characters anywhere?
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.
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?
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.
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.
Yeah, I don’t know of a way to do this in Javascript land.
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.
Yeah, that would work as long as you don’t mind keeping up with that list.
It would only be in one that I would manage it. Static Resource javascript. Starting to really enjoy Sublime Text 3 w/ Mavensmate.
Here’s a simple example if you need something to get started with:
function EntityPrefixDecoder(recordID) {<br> var prefixEntityMap = {<br> '001': 'ACCOUNT',<br> '002': 'NOTE',<br> '003': 'CONTACT'<br> };<br> if (recordID === null || (recordID.length !== 15 && recordID.length !== 18)) {<br> return null;<br> }<br> return prefixEntityMaparecordID.slice(0, 3)];<br>}<br>var id = '00290000000jPatPAT';<br>console.log(EntityPrefixDecoder(id));
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.