• Shivkumar Shete
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 23
    Replies
trigger CloneOpp1 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.get(record.opportunity_clone__c).put(field,record.getSObject(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update co2.values();
}

but getting error as variable does not exist :opportunity_clone_cc
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.get(record.opportunity_clone__c).put(field,record.getSObject(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update co2.values();
}

 
trigger CloneOpp1 on Opportunity( after insert, after update ) {
  Set<String> field = Opportunity.getDescribe().fields.getMap().keySet();
  Map<Id,Opportunity_clone__c> opp = new Map<Id,Opportunity_clone__c>();
  for(Opportunity record: Trigger.new) {
    opp.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.get(record.Opportunity_clone__c).put(field,record.get(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update Opportunity_clone__c.values();
}

 
trigger CloneOpp1 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.get(record.opportunity_clone__c).put(field,record.getSObject(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update co2.values();
}

but getting error as variable does not exist :opportunity_clone_cc
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.get(record.opportunity_clone__c).put(field,record.getSObject(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update co2.values();
}

 
trigger CloneOpp1 on Opportunity( after insert, after update ) {
  Set<String> field = Opportunity.getDescribe().fields.getMap().keySet();
  Map<Id,Opportunity_clone__c> opp = new Map<Id,Opportunity_clone__c>();
  for(Opportunity record: Trigger.new) {
    opp.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.get(record.Opportunity_clone__c).put(field,record.get(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update Opportunity_clone__c.values();
}