• Satapon Wongsiri
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I add article type to my package but target org enable knowledge lighting
and I don't need to delete article type in my package.

How to fix solution this?

thank you 
Hi Everyone,

I stuck with this error now give me some solution.

ERROR 
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: []

Thank you for Help 

This code 
@isTest
public class UpdateOpportunityToTotalValueTest {
    @isTest
    static void testInsertOpportunityLineItems() {
       
        Pricebook2 priceBook = new Pricebook2(Name = 'Test Pricebook');
        insert priceBook;
       
        Pricebook2 standardPB = [SELECT Id FROM Pricebook2 WHERE isStandard=true LIMIT 1];
       
        Product2 product1 = new Product2(
            Name = 'Product1',
            ProductCode = 'P1',
            Description = 'Product Test 1'
        );
        Product2 product2 = new Product2(
            Name = 'Product2',
            ProductCode = 'P2',
            Description = 'Product Test 2'
        );
        insert product1;
        insert product2;
        PricebookEntry standardPrice = new PricebookEntry(
             Pricebook2Id = standardPB.Id,
             Product2Id = product1.Id,
             UnitPrice = 10000,
             IsActive = true,
             UseStandardPrice = true          
        );
        insert standardPrice;
        PricebookEntry priceCustom1 = new PricebookEntry(
            Pricebook2Id = priceBook.Id,
            Product2Id = product1.Id,
            UnitPrice = 100.00,
            UseStandardPrice = false,
            IsActive = true
        );
        insert priceCustom1;
       
        PricebookEntry priceCustom2 = new PricebookEntry(
            Pricebook2Id = priceBook.Id,
            Product2Id = product2.Id,
            UnitPrice = 50.00,
            UseStandardPrice = false,
            IsActive = true
        );
       
        insert priceCustom2;
       
        Opportunity testOpportunity = new Opportunity(
            Name = 'Test Opportunity',
            StageName = 'Closed Won',
            CloseDate = Date.today(),
            TotalValue__c = 0,
            Pricebook2Id = priceBook.Id
        );
        insert testOpportunity;
       
        OpportunityLineItem oline1 = new OpportunityLineItem(
            OpportunityId = testOpportunity.Id,
            PricebookEntryId = priceCustom1.Id,
            Quantity = 2
        );
        OpportunityLineItem oline2 = new OpportunityLineItem(
            OpportunityId = testOpportunity.Id,
            PricebookEntryId = priceCustom2.Id,
            Quantity = 1
        );
        List<OpportunityLineItem> oppLineToUpdate = new List<OpportunityLineItem>{oline1, oline2};
        insert oppLineToUpdate;
        testOpportunity = [SELECT TotalValue__c FROM Opportunity WHERE Id = :testOpportunity.Id];
        System.assertEquals(250.00, testOpportunity.TotalValue__c);
    }
}