Skip to main content
Can anyone help with the below: 

 

I'm trying to stop this trigger from creating an extra object every time the Opportunity page is updated. 

 

trigger createPMPage on Opportunity (after update) {

 

    List <Project_Management__c> PMInsert  = new List <Project_Management__c> ();

 

   

 

  

 

for (Opportunity o : Trigger.new)

 

    {

 

         Project_Management__c p = new Project_Management__c ();

 

 

 

  if (o.Job_Type__c == '1' ) 

 

     

 

        {

 

   p.Project__c = o.Id;

 

         p.Name = o.Name;

 

         p.OwnerId = '005b0000000hZc9';   

 

         if( o.Stage_One__c != Null){

 

             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if

 

        }//end if

 

       

 

        if (o.Job_Type__c == '2'  )

 

        {

 

        p.Project__c = o.Id;

 

  p.Name = o.Name;

 

        p.OwnerId = '005b0000000hIRM';

 

        if( o.Stage_One__c != Null){

 

             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if

 

        }//end if

 

       

 

         if (o.Job_Type__c == '3'  )

 

        {

 

   p.Project__c = o.Id;

 

         p.Name = o.Name;

 

         p.OwnerId = '005b0000000jCjP';

 

         if( o.Stage_One__c != Null){

 

             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if

 

        }//end if

 

 

 

       

 

        if(trigger.newMap.get(o.name) != trigger.OldMap.get(p.Project__c)){

 

         PMInsert.add(p);

 

         }

 

 

 

  }//end for

 

  insert PMInsert;

 

     }//end trigger
1 resposta
  1. 10 de set. de 2014, 17:03
    This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to

     

    the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.
0/9000