You need to sign in to do that
Don't have an account?
gaganSFDC
Create Generic method for 2 different object having same fields api
Hi, i want to merge these methods and create one generic method, so that i will have to pass the type of object only as both the object having same fields.
//update Lead
private static void updateLead(Map<String,String> dataMap){
Lead obj = new lead();
obj.Id= dataMap.get('Id');
obj.Current_Assets_Type_of_Charge__c = 'abcd';
obj.Single_state_Remarks__c = 'xyz';
obj.More_than_3_months__c = 'pqr';
obj.More_than_3_months_Remarks__c ='asdf';
update obj;
}
//update opportunity
private static void updateOpportunity(Map<String,String> dataMap){
Opportunity obj = new Opportunity();
obj.Id= dataMap.get('Id');
obj.Current_Assets_Type_of_Charge__c = 'abcd';
obj.Single_state_Remarks__c = 'xyz';
obj.More_than_3_months__c = 'pqr';
obj.More_than_3_months_Remarks__c ='asdf';
update obj;
}
//update Lead
private static void updateLead(Map<String,String> dataMap){
Lead obj = new lead();
obj.Id= dataMap.get('Id');
obj.Current_Assets_Type_of_Charge__c = 'abcd';
obj.Single_state_Remarks__c = 'xyz';
obj.More_than_3_months__c = 'pqr';
obj.More_than_3_months_Remarks__c ='asdf';
update obj;
}
//update opportunity
private static void updateOpportunity(Map<String,String> dataMap){
Opportunity obj = new Opportunity();
obj.Id= dataMap.get('Id');
obj.Current_Assets_Type_of_Charge__c = 'abcd';
obj.Single_state_Remarks__c = 'xyz';
obj.More_than_3_months__c = 'pqr';
obj.More_than_3_months_Remarks__c ='asdf';
update obj;
}
Can you try as below,
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,