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
uat_live1.3903047664538198E12uat_live1.3903047664538198E12 

Constructor not defined: [SObject].<Constructor>()

Hi All,

I get the Below Error When I Initialise an S Object Instance. Could Some one Please let me know how I can Initialise it.

Public Sobject NewSObject = New SObject(); 

Error: Constructor not defined: [SObject].<Constructor>()

Thanks and Regards,
Christwin
Best Answer chosen by uat_live1.3903047664538198E12

All Answers

Anoop yadavAnoop yadav
This was selected as the best answer
Iqrar AhmedIqrar Ahmed
Hi Uat_Live,

You can initialize dynamic sobject in following way

You can use the following code to create an SObject dynamically:

sObject sObj = Schema.getGlobalDescribe().get(ObjectName).newSObject() ;

where ObjectName is can be a name of any object like contact,account,opportunity

Best Regards
IQRAR AHMED
Senior Salesforce/.Net Developer