You need to sign in to do that
Don't have an account?
Jake Gmerek
Trigger update issue
Hello I have three objects Order__c, Serial_number__c and path__c
Serial Number has a look up on order and is the master of path. Path has a lookup on order.
Before inserting a path record I am trying to automatically get the order field filled in by using the serial number. Here is my trigger:
trigger addOrder on Path__c (before insert) {
for (integer i = 0; i < trigger.new.size(); i++){
trigger.new[i].order__c = trigger.new[i].serial_number__r.Order__r.id;
}
}
It does not return an error, but just leaves the Lookup field on Path blank. Any Ideas on why this is not working?
Thanks
In a before insert trigger, __r relationship references will evaluate to null.
You will therefore need to query for the SerialNumbers before setting the reference
I wrote a little blog post explaining this http://cloudnow.wordpress.com/2011/04/04/apex-bloopers-why-art-thou-null/
All Answers
In a before insert trigger, __r relationship references will evaluate to null.
You will therefore need to query for the SerialNumbers before setting the reference
I wrote a little blog post explaining this http://cloudnow.wordpress.com/2011/04/04/apex-bloopers-why-art-thou-null/
Good Deal, Thanks I got it now