You need to sign in to do that
Don't have an account?
FdeBergeyck
Use of parent-child relationships
Hello,
Is there a way to access data through a parent child relationship without using a querry?
I have an object Vehicle__c where the field Driver__c is a lookup to a Contact. I would like to have the AccountId of that contact. I tried the following, but it returns always null (although the AccountId of that Contact is not null):
for(Vehicle__c vehicle : System.trigger.new){
System.debug('vehicle.Driver__r.AccountId = '+vehicle.Driver__r.AccountId);
}
Is there another way, or do I have to use a querry?
Thanks for your help,
François de Bergeyck
Yes, I've heard of a way of accessing these kind of data without using a query but some API.
Is that right? Where to start for that? It isn't the Metadata API, is it?
Maybe somebody can give as a hint. Would be great.
Cheers,
Matthias
String accountId = [select AccountId from Contact where Id = :vehicle.Driver__c][0].AccountId;
Message Edited by jf317820 on 02-15-2008 09:13 AM