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
horoshhorosh 

Apex referece between customer objects

I am fairly new to Apex and Force.com in general. I have been going through the Force.com Workbook (the one that comes with Eclipse Force IDE Help File) which has an example Adding Apex Trigger, with the following code:

trigger HandleProductPriceChange on Merchandise__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 j.Merchandise__r.id IN :Trigger.new
   FOR UPDATE];

}

The problem: The reference  j.Invoice_Statement__r.Status__c don't work. The code code-complete-assist show me j.invoice_Statement__r and I can't see Status__c attribut.
Error: "Save error: Didn't understand relationship 'Unit_Price__c' 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.    Force.com save problem"

Can you help me please? Thank

StephenJacobGoldbergStephenJacobGoldberg

try this

 

 

 

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 j.Merchandise__c IN :Trigger.new
   FOR UPDATE];

}