• SalesForce China beginners
  • NEWBIE
  • 25 Points
  • Member since 2012

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

I create test in class, appear a mistake

 

System.DmlException:Insert failed.First exception on row 0;

 

first error:CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, createPriceBookEntry

 

execution of AfterInsertcaused by:System.ListException List index out of bounds:

 

OTrigger.createPriceBookEntry:line 7

 

 

 

I really found the trigger, the following should be how to do? What is the problem?              Thank you

Hello, senior,

 

and I met above problem 'No standard price defined for this product',
I try to use

      'Pricebook2 pricebook = [Select p.I d, p.N ame from Pricebook2 p where isActive = true and isStandard = true Limit 1];       'code for object, but called the

      ' List has no rows for assignment to SObject 'mistakes

       don't know what to do, hope to get solutions thank

Hello, senior,

 

and I met above problem 'No standard price defined for this product',
I try to use

      'Pricebook2 pricebook = [Select p.I d, p.N ame from Pricebook2 p where isActive = true and isStandard = true Limit 1];       'code for object, but called the

      ' List has no rows for assignment to SObject 'mistakes

       don't know what to do, hope to get solutions thank

hi,

I'm trying to create a test class for a trigger:

 

trigger deleteTask on OpportunityLineItem (before delete) {

List<OpportunityLineItem> OppLIs = Trigger.old;
List<Task> tasks = new List<Task>();

for (OpportunityLineItem OppLI : OppLIs) {

Opportunity Opp = [ Select OwnerId from Opportunity where id=:OppLI.OpportunityId limit 1 ];
User usuario = [ Select Sociedad__c from User where id=:Opp.OwnerId ];

//el usuario debe pertenecer a argentina = usuario.Sociedad__c == 1000
if ( usuario.Sociedad__c == '1000' ) {
tasks = [ Select Id from Task where whatID=:OppLI.OpportunityId and Subject='Recordatorio: Vencimiento de producto'];
}
}

delete tasks;

}

 

My test class is:

 

@isTest
private class deleteTaskTest {

static testMethod void myUnitTest() {

//Create a custom pricebook
Pricebook2 pb = new Pricebook2(Name='Custom Pricebok',IsActive=true);
insert pb;

// Create a new product
Product2 prod = new Product2(IsActive=true, Name='Product');
insert prod;

// Create a pricebook entry for custom pricebook
PricebookEntry pbe2 = new PricebookEntry(Pricebook2Id=pb.Id, Product2Id=prod.Id,
IsActive=true, CurrencyIsoCode='ARS', UnitPrice=100,

  UseStandardPrice=false);

insert pbe2;

test.startTest();

delete prod;

test.stopTest();

}
}

 


When I run this test class, I get this error message:

 

 Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

In the line: insert pbe2;

 

 Can someone understand why this is happening? Thanks!

  • December 07, 2009
  • Like
  • 0