function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ashish jadhav 9ashish jadhav 9 

what is sobject casting?

What is the use of casting?
Piyush Kumar 58Piyush Kumar 58
Hi,

sObject casting when you use generic sobject and then convert that into a concrete sobject.
example:-
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
Schema.SobjectType oType = gd.get(‘account’);
account object_instance = (account)oType.newSObject();
Thanks.
 
sandeep@Salesforcesandeep@Salesforce
Hi Ashish, 

Adding in to previous response. If you need dynamic Objec casting you may refer: 
https://developer.salesforce.com/forums/?id=906F00000008zKNIAY

Thanks 
Sandeep Singhal