• ShawnaFisher
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

I am very new to APEX code, and I have created a trigger:

 

trigger AddSRSplit on Opportunity (after insert) {

Sales_Rep_Split_Revenue__c[] splitList = new Sales_Rep_Split_Revenue__c[]{};


    for (Opportunity o : Trigger.new) {


    splitList.add(new Sales_Rep_Split_Revenue__c
    ( Name = 'No Split',
          opportunity__C = o.ID,
          Split__c = 100,
          Sales_Rep__c = o.OwnerId )); }

        insert splitList; }

 

that i need a test case for.  I have not a clue on what I need to do.  Any help would be appreciated!

I need to insert a record into a custom object on save in opportunity.  Here is my trigger:

 

trigger AddSRSplit on Opportunity (after insert) {       

 

      for (Opportunity o : Trigger.new) {    

          

      Sales_Rep_Split_Revenue__c Split= new Sales_Rep_Split_Revenue__c         

           

                   ( Name = 'No Split',          

                     opportunity__C = o.ID,          

                     Split__c = 100,                        

                     Sales_Rep__c = o.owner);   

       insert Split;                                   }                                                

                                                                         }

 

 

The problem is that I can not get the opportunity owner to be the sales rep name in the custom object, it keeps failing saying that an ID is expected.  Any help would be appreciated!

 

 

 

I need to insert a record into a custom object on save in opportunity.  Here is my trigger:

 

trigger AddSRSplit on Opportunity (after insert) {       

 

      for (Opportunity o : Trigger.new) {    

          

      Sales_Rep_Split_Revenue__c Split= new Sales_Rep_Split_Revenue__c         

           

                   ( Name = 'No Split',          

                     opportunity__C = o.ID,          

                     Split__c = 100,                        

                     Sales_Rep__c = o.owner);   

       insert Split;                                   }                                                

                                                                         }

 

 

The problem is that I can not get the opportunity owner to be the sales rep name in the custom object, it keeps failing saying that an ID is expected.  Any help would be appreciated!