Scenario: I got a VF Page where I will get only ID's
of various Objects, I wouldn't know which Object RecordID
I would be getting in an instance. I need to update that record with that ID. Without knowing which Object, I can't create an instance of that object to update.
I need to update that list, where Objects could be of any type Accounts, Contacts Or any Custom Object.
Please advise, How can I achieve this.
Best Answer
You can instantiate an
sObject
record from anId
without knowing its type.As already mentioned by Tushar, you can mix types in your operation, up to 10 types. You could do something like the following to flexibly support an arbitrary number of objects. It's just a sketch of what you need to implement; obviously you will have to test it and tweak to suit your needs. You may want to add some governor protections and other safeguards.