You need to sign in to do that
Don't have an account?
RDN_LHR
for ( Contact loopContact : Trigger.new )
SOQL Join in Maps
Hi,
I would like to automatically assign certain records to their Account Owners on insert. In this particular version,
I am trying to do this only when the Owner has IsActive=true in the User table. I'm guess that while this SOQL statement is ok in real life, it doesn't work in a map.
Map<Id, Account> accMap = new Map<Id, Account>([select Id, OwnerId, Owner.isActive
from Account where Id in :accSet]);
from Account where Id in :accSet]);
for ( Contact loopContact : Trigger.new )
{
if (accMap.get(loopContact.AccountId).isActive = true)
if (accMap.get(loopContact.AccountId).isActive = true)
{
loopContact.OwnerId = accMap.get(loopContact.AccountId).OwnerId;
}
loopContact.OwnerId = accMap.get(loopContact.AccountId).OwnerId;
}
else {
// do something else
// do something else
}
JimRae
One little change and it should work:
Code: