• jsymonds
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies

I have written a simple Opportunity trigger to update a field in Opportunity Line Item records when an Opportunity is moved to certain stages.  I am now trying to write a test class so I can deploy it to my production server.  When I run the test (code is listed below),  I get the error:

 

15:15:27.915 (915680000)|EXCEPTION_THROWN|[17]|System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

My test data includes creating test records for Pricebook2, Product2 and PricebookEntry, but none of these objects have a field for the Standard Price and I can't find it in any other object.

 

Does anyone know where the Standard Price is stored?    Below is my test class code - I am just trying to get this simple test to run then I'll be adding more test cases.

 

-----------------------------------------------------------------------

@isTest

private class TestUpdateClosedListPrice {

static testMethod void TestUpdateClosedListPrice() {

Opportunity opp1 = new Opportunity (Name='Opp1',StageName='Stage 0 - Lead Handed Off',CloseDate=Date.today());
insert opp1;

Pricebook2 pbk1 = new Pricebook2 (Name='Test Pricebook Entry 1',Description='Test Pricebook Entry 1');
insert pbk1;

Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1');
insert prd1;

PricebookEntry pbe1 = new PricebookEntry (Product2ID=prd1.id,Pricebook2ID=pbk1.id,UnitPrice=50);
insert pbe1;

OpportunityLineItem lineItem1 = new OpportunityLineItem (OpportunityID=opp1.id,PriceBookEntryID=pbe1.id,Closed_List_Price__c=0);
insert lineItem1;

Test.startTest();

opp1.StageName='Stage 8 - Shipped';
update opp1;
System.assertNotEquals(0, lineItem1.Closed_List_Price__c);

Test.stopTest();
}
}

 

 

 

 

I am working on a trigger for the PricebookEntry standard object, but get the following error when I try to deploy it to my company sandbox:

 

'SObject type does not allow triggers: PricebookEntry'

 

Can anyone confirm that PricebookEntry does not allow triggers and/or have any idea why it wouldn't? 

 

 

I would like to add a custom field from the Products object to the Opportunity Product object.  For example, for each product we specify a custom field call Product Family.  I would like to include that field in the product records listed in an Opportunity such that when I add/update an Opportunity Product item the correct Product Family value is displayed for the selected Product. 
 
So far, I've added a Product Family field to the Opportunity Product and I've setup a workflow rule to update the field on new/update of records.  To fill-in the value, I've tried to use ISPICK() and CASE() but I've reached a dead end.  Any help would be *much appreciated*.
 
Jeff

I have written a simple Opportunity trigger to update a field in Opportunity Line Item records when an Opportunity is moved to certain stages.  I am now trying to write a test class so I can deploy it to my production server.  When I run the test (code is listed below),  I get the error:

 

15:15:27.915 (915680000)|EXCEPTION_THROWN|[17]|System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

My test data includes creating test records for Pricebook2, Product2 and PricebookEntry, but none of these objects have a field for the Standard Price and I can't find it in any other object.

 

Does anyone know where the Standard Price is stored?    Below is my test class code - I am just trying to get this simple test to run then I'll be adding more test cases.

 

-----------------------------------------------------------------------

@isTest

private class TestUpdateClosedListPrice {

static testMethod void TestUpdateClosedListPrice() {

Opportunity opp1 = new Opportunity (Name='Opp1',StageName='Stage 0 - Lead Handed Off',CloseDate=Date.today());
insert opp1;

Pricebook2 pbk1 = new Pricebook2 (Name='Test Pricebook Entry 1',Description='Test Pricebook Entry 1');
insert pbk1;

Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1');
insert prd1;

PricebookEntry pbe1 = new PricebookEntry (Product2ID=prd1.id,Pricebook2ID=pbk1.id,UnitPrice=50);
insert pbe1;

OpportunityLineItem lineItem1 = new OpportunityLineItem (OpportunityID=opp1.id,PriceBookEntryID=pbe1.id,Closed_List_Price__c=0);
insert lineItem1;

Test.startTest();

opp1.StageName='Stage 8 - Shipped';
update opp1;
System.assertNotEquals(0, lineItem1.Closed_List_Price__c);

Test.stopTest();
}
}

 

 

 

 

I am working on a trigger for the PricebookEntry standard object, but get the following error when I try to deploy it to my company sandbox:

 

'SObject type does not allow triggers: PricebookEntry'

 

Can anyone confirm that PricebookEntry does not allow triggers and/or have any idea why it wouldn't? 

 

 

I would like to add a custom field from the Products object to the Opportunity Product object.  For example, for each product we specify a custom field call Product Family.  I would like to include that field in the product records listed in an Opportunity such that when I add/update an Opportunity Product item the correct Product Family value is displayed for the selected Product. 
 
So far, I've added a Product Family field to the Opportunity Product and I've setup a workflow rule to update the field on new/update of records.  To fill-in the value, I've tried to use ISPICK() and CASE() but I've reached a dead end.  Any help would be *much appreciated*.
 
Jeff