Please Login with your Salesforce ID to post, promote or comment.
Salesforce IdeaExchange
FAQs | Terms of Use8282 Ideas; Promoted 177419 Times; 17086 Comments.
- Suggest a New Product Concept
- Promote Ideas That You Want to See Developed
- Discuss With Product Managers and Other Users
- See What We Are Planning To Deliver
Administration Comments
| Administration Ideas
|
Customization Comments
| Customization Ideas
|
Web Services API Comments
| Web Services API Ideas
|
Force.com Platform Comments
| Force.com Platform Ideas
Function to determine object type for whoId and whatId
Tasks and Events have two fields (whoId and whatId) that can reference multiple object types ... whoId => Lead|Account, whatId => Account|Asset|Campaign|Case...
I'd like to see a function that would return the name of the object type being referenced that we could use in S-controls, formula fields, reports, etc.
e.g. {!$ObjectTypeName(WhoId)}
This would allow someone working on a Task record to do queries on the related object like so:
var queryResult = sforce.connection.query("Select Name from {!$ObjectTypeName(WhoId)} where Id='{!WhoId}'");
... or construct different query strings depending on the object type returned.
|
hemm Apr 17 |
You can get this pretty easily now. The first 3 characters of every ID tell you what object it is. Standard Objects have the same prefix in every org. Custom Objects take a little digging. If you do a describeSObjects call, you can get the Prefix parameter to officially get the prefix for an object. You can also get it easily by looking at a tab's URL. For example, the Account tab's URL is https://na1.salesforce.com/001/o/ The prefix is 001. Some common ones: Lead: 00Q Account: 001 Contact: 003 Opportunity: 006 Case: 500 |
|
mtbclimber Jul 25 |
If all you want is the name then you can do this today with SOQL relationships. For example: [Select Who.name from task where id = :taskid]; Polymorphic relationships like who and what on task/event or owner on queue-ownable objects can be traversed. The object that is returned is called "Name". Here's the information you can access through this traversal: (from the enterprise WSDL) Alias FirstName LastName Name Type UserRole UserRoleId |
Please log in to post a comment
recently promoted by:
- fhkazmi@yahoo.com
- venkat_polisett
- Wilmer
- sparky
- ChrisMcL
- Rusty12
- EricCH
- ron_wild