
3 respostas
David - Try the below code to get the lookup field values in the before insert operation
trigger MyTrigger on Case(before insert) {
Set<Id> AccountIds = new Set<Id>();
for (Case cs: Trigger.new) {
if (cs.AccountId != null) {
AccountIds.add(cs.AccountId);
}
}
Map<Id, AccountId> accountEntries = new Map<Id, Account>(
[select Id,Name from Account where id in :AccountIds]
);
for (Case caseRec : Trigger.new) {
String accountName = accountEntries.get(caseRec .AccountId).Name; //Getting Account name, similarly you can get other field value as well
//your logic
}
}