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

Apex trigger

trigger HandleProductionPriceChange on<a href=""> rolex </a> Marchandise__c (after update) {
List<Line_Item__c> openLineItems=[SELECT j.Unit_Price__c,j.Merchandise__r.Price__c FROM Line_Item__c j
 WHERE j.Invoice_Statement__r.Status__c='Negotiating' AND IN FOR UPDATE];

for(Line_Item__c Ii:openLineItems){
if(Ii.Merchandise__r.Price__c < Ii.Unit_Price__c){
 update openLineItems;




Error: Compile Error: Didn't understand relationship 'Merchandise__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 2 column 34




Unable to figure out the problem.

I had written this trigger on force IDE and while saving it gave an error :File only saved locally,not to server



I think you have created an Object with Name Marchandise__c and you are using Merchandise__r. So make sure that you are using the same. Your code should be like this:
trigger HandleProductionPriceChange on Marchandise__c (after update)
List<Line_Item__c> openLineItems=[SELECT j.Unit_Price__c,j.Marchandise__r.Price__c FROM Line_Item__c j
WHERE j.Invoice_Statement__r.Status__c='Negotiating' AND IN FOR UPDATE];

for(Line_Item__c Ii:openLineItems){
if(Ii.Marchandise__r.Price__c < Ii.Unit_Price__c){
update openLineItems;

Ronak PatelRonak Patel

Just Check whether merchandise___c is a master detail relationship with line item and also check the fileds in the both custom objects.

Aravind SriramAravind Sriram

Hi Roger,


Verify the API name for the field(look up/Master Detail) in the Line Item object. Thats the mistake. Otherwise i couldn't see any problem.


you are writing the trigger on Marchandise__c .. but unfortunately a typo mistake in your code .. Merchandise__c (u need to correct this)