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
sagar patil 13sagar patil 13 

How To Create Generic Class for SObject

EldonEldon
Hi sagar,

Please try the below code,
 
String sObjectName = 'Contact';
Schema.SObjectType t = Schema.getGlobalDescribe().get(sObjectName);
SObject s = t.newSObject();
s.put('LastName', 'TestGeneric');
insert s;


Hope this helps.
Regards