• Nidhi Gupta
  • NEWBIE
  • 5 Points
  • Member since 2014
  • Cognizant Technology Solutions

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
I wrote a trigger that is supposed to clone an opportunity whenever its stage is set to "Closed Won." It's running without errors, but when I create a new opportunity and change its stage to "Closed Won" and then check the list of opportunities, there is no new opportunity. I think I'm cloning the opportunity correctly, but I don't know how to push it to the list of opportunities and give it a name.

here's my trigger:

trigger Create_followup on Opportunity (before update) {

if(Trigger.isUpdate){

List<Opportunity> listOppor = new List<Opportunity>();
for (Opportunity o: Trigger.new){

    if (o.StageName == 'Closed Won' && o.Stage_Change__c == false){

        Opportunity oppNew = o.clone();
        listOppor.add(oppNew);
        o.Stage_Change__c = true;
}

    if(listOppor.size() > 0){
        
        insert listOppor;
}
}
}
}

Thanks in advance for your help! 
I have populates core field value from Property to its related Cntact 's Account ...on Account the field name is Core
trigger updateAccCorefrmProperty2 on Property__c (after insert, after update, after delete) {


      Set<Id> accid = new Set<Id> ();
      Set<Id> conids= new Set<Id> ();
        Set<Id> conids2= new Set<Id> ();
      Map<id,Id> mpConAccIds= new Map<id,Id>();        
      Map<id,List<Contact>> mpConAccIds2= new Map<id,List<Contact>>();        
      Map<id,List<Property__c>> mpConProp = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      Map<Id,Set<String>> mpCores = new Map<id,Set<String>> ();
      List<Account> acco = new List<Account>();
      set<id>  propids= new set<id> ();
           
    if(Trigger.IsInsert || Trigger.IsUpdate ) {
       for(Property__c prp: [select id,core__c ,Contact__c,Contact__r.Accountid,Contact__r.Account.core__c from Property__c where id in : Trigger.new] )
       {
        if(prp.Contact__c!=null && prp.core__c !=null)
        accid.add(prp.Contact__r.Accountid);
        
        }
       }
 
    if(Trigger.IsDelete ){
     
         for(Property__c prp :Trigger.old){
             if(prp.Contact__c!=null && prp.core__c !=null)
             propids.add(prp.Contact__c);        
         }
         
         for(Contact con: [select id, AccountId from Contact where id in : propids] )
         {  
              
            accid.add(con.Accountid);
         }    
     }    
    
       for(Account acc: [select id,(select id,AccountId from Contacts) from Account where id in : accid]){
       
          mpConAccIds2.put(acc.id,acc.Contacts);
       
              for(Contact con : acc.Contacts){
                  conids.add(con.id);
               }      
       }
       
       
       for(Contact cont: [select id,(select id,Core__c from Properties__r where Core__c !=null) from Contact where id in : conids2]){
       
       if(cont.Properties__r !=null)
           mpConProp.put(cont.id,cont.Properties__r);
           
           }

          
          
           for(id acc: mpConAccIds2.keyset()){
               PropCores.clear();
               for(Contact cons : mpConAccIds2.get(acc) ){
                   for(Property__c prop: mpConProp.get(cons.id) ){
                       if (prop.core__c != null){
                           PropCores.add(prop.core__c);                   
                       }
                    }
                   
                   }    
               
                     mpCores.put(acc,PropCores);           
               
               }
               
      String new_propCore;
       
       for(Account acc : [select id,core__c from Account where id in :mpCores.keyset()]){
           for(String str: mpCores.get(acc.id)){
               if(new_propCore!=null)
                   new_propCore+= ','+str;
               else{
               new_propCore=str;
               }    
           }
               acc.core__c =new_propCore ;
               acco.add(acc);
       }
       
 
       if(acco.size()>0)
       update acco;
        
        

}
The problem I have is that an old TestTrigger classe that was setup in 2013 is causing an error because the field type of the Custom Object Name field was changed from Text to Autonumber. No matter what I try, I cannot change the field name in the Test Class. I have tried to use Eclipse and Force.com IDE to comment out the field, rename it, and save it but I always get the same error
Eclipse Save Error

I have been able to save the changes to my sandbox, but when I validate the Change Set, the error comes up again:
Inbound Change Set valdiation error

This seems like such a simple problem to resolve, but now I have spent hours on it! Does anyone have any suggestions to get around this? Thanks in advance if you have any suggestions!
I recently installed EchoSign for Salesforce and finally have things up and running with my users being able to send documents with a single click. Now, I need to take it one step further and figure out a way to send a contract without user interaction, at the time a record (Lead) is created. 

Adobe talks about workflows in thier marketing but offers no obvious direction as to how to go about setting them up. As far as I can tell, this is not something which is a part of standard workflows so it sounds like I'm going to have to write another trigger??

Well, I've written a few triggers in the past but I am far from an expert. I can do it, I just need something to show me the way... I would appreciate any links or code snippets that anyone could offer. I'm sort of lost at this point and Adobe help & support is basically non-existent.

Thank you!

PS: I know how to find the basic Salesforce help guides on Apex Triggers - I need something specific to EchoSign. Thanks!