3 answers
My code is working but I want Quotation Line Item Number also into Project to know from which Quotation Line Item's respective which Project has been created but I am not getting that.Please Help me That following is my code, Project_Management__c = POSubProject__c= Projecttrigger CreateProjecttLineItems on Project_Management__c (after insert) { List<SubProject__c> PItem = new List<SubProject__c>(); Set<Id> setAccountId = new Set<Id>(); Map<Id,Integer> mapAccountIdCount = new Map<Id,Integer>(); for (Project_Management__c PM : trigger.new) { setAccountId.add(PM.Quote_Name__c); } for(Quote__c a : [Select Id,(Select Id,Product__c from Quotation_Line_Items__r) from Quote__c where id =: setAccountId]) { mapAccountIdCount.put(a.Id,a.Quotation_Line_Items__r.size()); } for (Project_Management__c PM: trigger.new) { for(Integer i=0; i<mapAccountIdCount.get(PM.Quote_Name__c);i++) { SubProject__c PBI = new SubProject__c(); PBI.Project_Name__c= PM.id; PBI.Kick_Off_Date__c=PM.Kick_Off_Date__c; PBI.Name=PM.Account_Name__c; PItem.add(PBI); } } insert PItem; }