You need to sign in to do that
Don't have an account?
SFNew
Know SObject type before Query/Retrieve
Hello,
I am writing a client that updates our orgs data to SF. I am using API. I'd like to know if there is any way to know the object type from SF Id? I get the ID from our DB. I do not want to retrieve an SObject and then know that it is not what I wanted. Any help in this regard is greatly appreciated. Thanks all.
The DescribeSObject API call will return, amongst many values, the keyPrefix which is the 3 digit prefix for the specific sObject type. You can use the DescribeGlobal API, iterate through all the types and make corresponding DescribeSObject calls to build the list of keyPrefixes for all sObjects in your org. Then compare that list against your data Ids.
All Answers
The DescribeSObject API call will return, amongst many values, the keyPrefix which is the 3 digit prefix for the specific sObject type. You can use the DescribeGlobal API, iterate through all the types and make corresponding DescribeSObject calls to build the list of keyPrefixes for all sObjects in your org. Then compare that list against your data Ids.