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> opp = new Map<Id,Opportunity_clone__c>();
- for(Opportunity record: Trigger.new) {
- Opportunity_clone__c oppclone = new Opportunity_clone__c();
- oppclone.id = record.Opportunity_clone__c;
- opp.put(record.Opportunity_clone__c,oppclone);
- for(String field:fields) {
- if(field.indexOf('__c')>-1) { // This is a custom field.
- try {
- opp.get(record.Opportunity_clone__c).put(field,record.get(field));
- } catch(exception e) { /* NOTE: This just means copy failed. */ }
- }
- }
- }
- update opp.values();
- }
Add Comment
Please, Sign In to add comment