+ Start a Discussion
Bhargavi TunuguntlaBhargavi Tunuguntla 

Insert records based on dynamically provided objectName

Hi All

I want to create a method which accepts object name and list of fields as parameters,this method should insert records to the object :

Public static void methodToInsert(String ObjectName,List<String> FieldNames)
{
//ObjectName -- holds the user passed object name
//fieldNames -- holds the names of the fields of that specific object (passed by user)
}

Generally my intention is to create records dynamically based on given object and field names

Thanks in Advance.
Raj VakatiRaj Vakati
I think your second arg must be a map< String , String> where key is object API name  and value is the value 

Refer this link 

https://salesforce.stackexchange.com/questions/159739/how-to-create-a-sobject-object