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
vasu takasivasu takasi 

How to create instance for an object based on Sobject type

string typename='account';

Schema.SObjectType targetType = Schema.getGlobalDescribe().get(typeName);

sObject obj=targetType.newSObject();


here i want to create an instance for account dynamically.

How is it possible.


Best Answer chosen by Admin (Salesforce Developers) 

This may give an idea of achieving your requirement,




Salesforce For All

Mark this post as solved, if it helps you