function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ubisense SupportUbisense Support 

Trigger Won't Deploy

For some odd reason my Trigger won't deploy because some unrelated test class is failing. Why would my unrelated "Case" trigger cause an "Opportunity" trigger test class to fail?

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code): [PricebookEntryId]", Failure Stack Trace: "Class.Opp_Trigger_Prod_Qty_Summary_Test_Class.val...

 

GunnarGunnar

Some  thoughts .

(1) Test coverage in the 'target' is not sufficient, and you don't have enough on your programs? Do you have 75% plus test coverage.

 

(2) When writing your tests, create your own test data in code. Do not rely on any data in an existing Salesforce instance.

 

(3) Is there any other trigger that is firing on any object you do any CRUD operation on? If so, you may have to add enough data to allow that trigger to complete successfully.

 

That is where I would look first.

Ubisense SupportUbisense Support

1) Test coverage is 100% in SF Sandbox

2) Did this.

3) The test class which fails and which is keeping my trigger from deploying is related to Opporutnities. My trigger is related to Cases so I don't get why this other test class even needs to be run?

 

Marko LamotMarko Lamot

One explanation could be:

Because you've probbly changed the product price currency you are likely using in test class. To the opportunity you can add only products that have same currency price than opportunity currency. And because you'r obviously trying to add the product price which has different currency than opportunity, this error pop-up's.

 

Why error now? When you did deployment, all tests re-executed and got chance to fail ;-)