You need to sign in to do that
Don't have an account?
![Santosh Shah 4 Santosh Shah 4](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
How To get AccountId from Quote in Before insert trigger
As per requirement while creating new Quote i have to update Quote field based on Account which Quote is holdinig..So i wrote trigger iin Before Insert.But Due to SF limitatin It will return AccountId always Null.How i can Map Quote with Account if there are multiple Quote with different account in trigger.new.Belowo is code
for(quote qrec :newRec){ if(string.isNotBlank(qrec.OpportunityId)){ oppsId.add(qrec.OpportunityId); } } List<Opportunity> oppsRec = [Select Id,AccountId FROM Opportunity WHERE ID = :oppsId]; for(Opportunity oppRec : oppsRec){ if(string.isNotBlank(oppRec.AccountId)){ accId.add(oppRec.AccountId); } } List<Account> accData = [SELECT Id,name,Partner_Rec__C FROM Account WHERE ID = :accId]; List<Partner> partnerRec =[SELECT AccountToId From Partner where AccountFromId = :accId]; //Perform only if Account doesnt have any partner Rec if(PartnerRec.size() == 0){ for(account acc : accData){ for(Quote qrec :newRec){ if(string.isBlank(acc.Partner_Rec__C) && string.isBlank(acc.ParentId) && ownerManagerMap.containskey(qrec.ownerid)){ qrec.Manager__c = ownerManagerMap.get(qrec.ownerID); } //How To know here which Quote Associated with which Account ?????Something like below // if(acc.Id == qrec.accountId) ---> Update Manger filed on Quote based on Account Availabe on Quote else if(string.isNotBlank(acc.Partner_Rec__C) && string.isNotBlank(acc.ParentId)){ qrec.Manager__c = acc.OwnerId; }