You need to sign in to do that
Don't have an account?
miku
How to know the sobject type according to the record Id
I create a task which whoid has a value to attach to a record .
If the task status is finished.I want to update the status of the attached record.
but how can I get the sobject type.only I konw is a Id.
Any suggestions would be greatly appreciated.Thanks
Here is the sample code to find out this :
http://www.iowntech.com/?p=204
But do visit the comments on the blog.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
All Answers
The id will have first three digits as Key Prefix , like for Account '001' , so get a substring fromID for Key
Step1:
String strID = '001ki0000000KIY';
String key = Split(0 , 3);
Step2:
//Do a Global descibe , and create map of all the object key Prefix
Step3:
Check in map which objects key matches
Here is the sample code to find out this :
http://www.iowntech.com/?p=204
But do visit the comments on the blog.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks It really fix my issue