You need to sign in to do that
Don't have an account?
Apex trigger
trigger HandleProductionPriceChange on<a href="http://www.buywatchesandjewelry.com/"> 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 j.Merchandise__r.id IN :Trigger.new FOR UPDATE];
for(Line_Item__c Ii:openLineItems){
if(Ii.Merchandise__r.Price__c < Ii.Unit_Price__c){
Ii.Unit_Price__c=Ii.Merchandise__r.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
Hi,
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 j.Marchandise__r.id IN :Trigger.new FOR UPDATE];
for(Line_Item__c Ii:openLineItems){
if(Ii.Marchandise__r.Price__c < Ii.Unit_Price__c){
Ii.Unit_Price__c=Ii.Marchandise__r.Price__c;
}
}
update openLineItems;
}
Just Check whether merchandise___c is a master detail relationship with line item and also check the fileds in the both custom objects.
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)