Account acc;
if(o.AccountId!=null) {
acc = [select id,GUP_GUID__c,OwnerId
from Account
where Id = : o.AccountId];
}
List<ECP__c> ecpList = [select id
from ECP__c
where Account__c = :acc.GUP_GUID__c
AND OwnerId= :o.OwnerId
AND Status_Internal__c='Active'];
if(ecpList.size()>0) {
ECP__c ecp = ecpList[0];
o.WCSS_ECP__c = ecp.Id;
update o;
}
Instead of getting the account first from Opportunity, is there a way to get Account out of Opportunity o directly in the ECP__c query(second one)?