Monday, November 14, 2016

How can you update Salesforce record using Apex, when you don’t know Object API name, but you know record Id ?

Using Dynamic Apex we can achieve this :
1//Lets assume this is record Id
2Id recId = 'a0P9000000ESXcV';
3 
4Schema.SObjectType token = recId.getSObjectType();
5Sobject s = token.newSobject();
6s.put('Id',recId );
7s.put('Name''om');
8update s;

No comments:

Post a Comment