3

This question is inspired by this Post. Can anyone enlighten me more about "object prepend" mentioned in this post.

So in an example URL like https://na10.salesforce.com/a0B/e?CF00NA0000005JzZX=Master1&CF00NA0000005JzZX_lkid=a0AA0000002CtHk&retURL=/a0AA0000002CtHk

that a0B is the object Prepend. I am not clear what is it. Does it change from one org to another (like Ids). If yes, then i need to find a way to get it dynamically in the custom button code.

Post mentions that object prepend can be obtained dynamically, using

Schema.getGlobalDescribe().get('Contact').getDescribe().getKeyPrefix()

the custom button i am creating, executes javascript on click. From there, how do i use Schema.getGlobalDescribe ? I have tried {!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}

but it is not the solution (I get "Schema is undefined").

Any suggestions on what is this object prepend and how to get it dynamically in a javascript button would be helpful. I am new to salesforce, and this forum is awesome and super helpful.

2

If the button is on standard object we can expect the prefix because it will remain same through the salesforce, but where as for the Custom object it changes from org to org. As you said in your question in apex code we can get the object prefix using the schema class but it does not support in button code, because the button code supports javascript. Even though we have a way to get the object prefix in a fair manner.Following line of code can fetch the object prefix.Use $objectType global variable.

alert('{!$ObjectType.YourCustomObjectAPIName__c}');

  • Worked like a charm. Thanks a lot. But i still want to understand what exactly is object prefix. – user2957592 Apr 28 '15 at 16:30
  • suppose if you take account record id always start with 001 , Contact 002, opportunity 006 ..... for standard objects. This is same through out the salesforce irrespective of org. But it is not the same with Custom objects. – Suresh Apr 28 '15 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.