I have Obj1 and Obj2 both having 20 fields of same API Names. For while creating Obj2 records I want to copy all those field values to Obj1. Is there any shortcut to do the coding instead of writing the whole thing.
Like below is the code.
for (Integer i = 0; i < srList.size(); i++ ) {
Database.SaveResult sr = srList[i];
if (sr.isSuccess()) {
//Alstitem.External_ID_vod__c = actID+'-'+key;
for(Business_Plan_abv__c j: accMap.get(BpToInsert[i].Territory_Name__c))
{
Business_Plan_Approval_Process_Data_abv__c bpdata = new Business_Plan_Approval_Process_Data_abv__c();
bpdata.Business_Plan_Approval_Process_abv__c= sr.getId();
bpdata.Territory_abv__c= BpToInsert[i].Territory_Name__c;
bpdata.External_Id_abv__c = j.Account_abv__c+'_'+sr.getId();
bpdata.Account_abv__c = j.Account_abv__c;
bpdata.City_abv__c = j.City_abv__c;
bpdata.Comments_abv__c = j.Comments_abv__c;
bpdata.Call_Priority_Decile_abv__c = j.Call_Priority_Decile_abv__c;
bpdata.Call_Activity_Avg_of_last_3_quarters_abv__c = j.Call_Activity_Avg_of_last_3_quarters_abv__c;
bpdata.Business_Planner_Flag_abv__c = j.Business_Planner_Flag_abv__c;
bpdata.Biologic_Index_last_6_months_abv__c = j.Biologic_Index_last_6_months_abv__c;
......................?? Instead of writing like this, is there any shortcut way to copy field values.
}
insbpdata.add(bpdata);
}
}