I need to update all contact records from one record to another record which has 333 fields. It takes time to update this. I thought of updating the sobject field dynamically, but I'm getting "Variable does not exist: fieldvalue" while saving the class.
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
Contact existingContact;
List<Schema.SObjectField> fieldsList = new List<Schema.SObjectField>();
Schema.SObjectType s = m.get('Contact');
Schema.DescribeSObjectResult r = s.getDescribe();
Map<String,Schema.SObjectField> fields = r.fields.getMap();
for(Contact con : ConList)
{
for(Schema.SObjectField fieldItems : fields.values()) {
Schema.DescribeFieldResult dfield = fieldItems.getDescribe();
if (dfield.isCreateable() && !dfield.isCalculated()) {
if(con.Id != existingContact.Id)
{
existingContact.fieldItems = String.isNotBlank(con.fieldItems ) ? con.fieldItems : existingContact.fieldItems ;
}
}
}
}
How can it resolved?