Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger CloneOpp on Opportunity( after insert, after update ) {
- Set<String> fields = Opportunity.getSobjectType().getDescribe().fields.getMap().keySet();
- Map<Id,opportunity_clone__c> co2 = new Map<Id,Opportunity_clone__c>();
- for(Opportunity record: Trigger.new) {
- co2.put(record.opportunity_clone__c,new opportunity_clone__c(id=record.opportunity_clone__c));
- for(String field:fields) {
- if(field.indexOf('__c')>-1) { // This is a custom field.
- try {
- Opportunity_clone__c.getSobject(record.opportunity_clone__c).put(field,record.get(field));
- } catch(exception e) { /* NOTE: This just means copy failed. */ }
- }
- }
- }
- update co2.values();
- }
Add Comment
Please, Sign In to add comment