You need to sign in to do that
Don't have an account?
Sony PSP
Trigger for a field
Hi Guys,
I have this Trigger wherein it sums up what is in the product forecast and puts it into Project in the field ex. Sum of Product Forecasted, but unfortunately it doesn't appear, my problem is that how can i move from agreement going to project so I can populate the field
public static void PFSumOEM (List<APTS_Product_Forecast__c> newProductForecast){
Set<ID> pdIds = new Set<ID>();
List<Project__c> OEMToUpdate = new List<Project__c>();
Double pfSum;
for(APTS_Product_Forecast__c pf: newProductForecast){
pdIds.add(pf.APTS_Price_Agreement__c);
}
for(APTS_Product_Forecast__c pf : [SELECT APTS_Quantity__c , Panel__c FROM APTS_Product_Forecast__c WHERE isDeleted = false AND panel__c != null AND apts_price_agreement__r.id = null AND product_is_primary__c = TRUE and Panel__c =: pdIds]){
System.debug('pf value = ' + pf);
pfSum +=pf.APTS_Quantity__c;
}
for(Project__c prj: [Select Id from Project__c where ID =: pdIds]){
prj.Tier1_Project_Forecast__c = pfSum;
OEMToUpdate.add(prj);
}
//Update the Project
if(!OEMToUpdate.isEmpty()){
update OEMToUpdate;
}
}
I have this Trigger wherein it sums up what is in the product forecast and puts it into Project in the field ex. Sum of Product Forecasted, but unfortunately it doesn't appear, my problem is that how can i move from agreement going to project so I can populate the field
public static void PFSumOEM (List<APTS_Product_Forecast__c> newProductForecast){
Set<ID> pdIds = new Set<ID>();
List<Project__c> OEMToUpdate = new List<Project__c>();
Double pfSum;
for(APTS_Product_Forecast__c pf: newProductForecast){
pdIds.add(pf.APTS_Price_Agreement__c);
}
for(APTS_Product_Forecast__c pf : [SELECT APTS_Quantity__c , Panel__c FROM APTS_Product_Forecast__c WHERE isDeleted = false AND panel__c != null AND apts_price_agreement__r.id = null AND product_is_primary__c = TRUE and Panel__c =: pdIds]){
System.debug('pf value = ' + pf);
pfSum +=pf.APTS_Quantity__c;
}
for(Project__c prj: [Select Id from Project__c where ID =: pdIds]){
prj.Tier1_Project_Forecast__c = pfSum;
OEMToUpdate.add(prj);
}
//Update the Project
if(!OEMToUpdate.isEmpty()){
update OEMToUpdate;
}
}
Can you post the source of your trigger? Without the trigger, it lacks the most important part. The source above should work if ...
System.debug('pf value = ' + pf.APTS_Quantity__c); in the loop shows values.
Alain