• Dev_Neil
  • NEWBIE
  • 0 Points
  • Member since 2010

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

I've got a trigger I wrote and put in our sandbox, it works great and production has all the same fields.  So now I have to build the class to test it. I thought I had it and it errors out instead.

 

The trigger is as follows and does work...

 

 

trigger OwnerLinkUpdate on Opportunity (before insert, before update ) {
 for (Opportunity a :Trigger.NEW) {
    a.Owner_Link__c = a.OwnerId;
    a.TM_Descr__c = a.Description.substring(1, 100); 
    }
}

 

trigger OwnerLinkUpdate on Opportunity (before insert, before update ) {

for (Opportunity a :Trigger.NEW) {

a.Owner_Link__c = a.OwnerId;

a.TM_Descr__c = a.Description.substring(1, 100);

}

}

 

And below is my class I currently have but know it is wrong.

 

@isTest

private class TestOwner_link {

 

    public static testMethod void OwnerLinkTest() {

     Opportunity o = [Select o.Id, o.Description FROM Opportunity o WHERE o.ID = '006Q0000005MIEK'];

o.Description = 'P123456789 - Appt Secured 9/21/2010 16:00 - Test Description to see if this will update correctly.';

        update o;

    

       Opportunity opp = new Opportunity(name = 'IS TEST 2' , StageName = 'Prospect',

        AccountId = '001Q000000EmsJs', OwnerId = '00580000001khcs',

        CloseDate = date.newinstance(2010, 10, 21), Product_Service_Type__c = 'Alarm',

        Product_Service_Detail__c = 'Burglar Alarm System', Type = 'NEW',

        Level__c = 'Recommended (We seek out the account to give them a proposal.)',

        LeadSource = 'Sales Rep Generated', Description = 'Text', External_ID__c = 'P123456789');

       insert opp;

 

    }

}

 

 

Any help would be appreciated, I have been reading posts and can't seem to find anything that seems to make the class work and the trigger cover 100%.

 

 

 

  • September 24, 2010
  • Like
  • 0