You need to sign in to do that
Don't have an account?
Forrest Muldune
Trigger - RollUp Summary - Opportunities and Custom Object
All,
I have a custom object Matter__c label is Engagement with a lookup relationship field Deal__c datatype Lookup(Opportunity) that connects to Opportunity. Opportunities object in my Salesforce database is rename to Deal__c .
I am requesting if the currency value in the custom currency (16,2) field Total_Fees__c in the custom object Matter__c which may contain one or more records , will Rollup Summary into the related Opportunity ( Deal__c ) record, within the custom currency (16,2) field Engagement_Total_Fees__c . For each Deal__c record there can be one or many Matter__c records.
I created a Trigger below but it is not working. I believe the trigger does not have coding that will place the currency values in the Total_Fees__c field in Matter__c records to be summarize in the Engagement_Total_Fees__c in the Deal__c record.
I am not an expert in triggers and I could appreciate the help.
trigger UpdateEngagementTotalFees on Matter__c (After insert,After update,After delete){
Set<String>dealIds= new Set<String>();
if(Trigger.isDelete){
for(Matter__c mat : Trigger.old){
dealIds.add(mat.Deal__c);
}
}else if(Trigger.isUpdate){
for(Matter__c mat : Trigger.New){
if(mat.Deal__c != trigger.oldMap.get(mat.id).Deal__c || mat.Total_Fees__c !=trigger.oldMap.get(mat.id).Total_Fees__c){
if(mat.Deal__c!=null)
dealIds.add(mat.Deal__c);
if(trigger.oldMap.get(mat.id).Deal__c!=null)
dealIds.add(trigger.oldMap.get(mat.id).Deal__c);
}
}
}else{
for(Matter__c mat : Trigger.New){
if(mat.Deal__c != null){
dealIds.add(mat.Deal__c);
}
}
}
if(dealIds.size()>0){
TriggerUtility.rollupBookValues(dealIds,'Matter__c');
}
}
I have a custom object Matter__c label is Engagement with a lookup relationship field Deal__c datatype Lookup(Opportunity) that connects to Opportunity. Opportunities object in my Salesforce database is rename to Deal__c .
I am requesting if the currency value in the custom currency (16,2) field Total_Fees__c in the custom object Matter__c which may contain one or more records , will Rollup Summary into the related Opportunity ( Deal__c ) record, within the custom currency (16,2) field Engagement_Total_Fees__c . For each Deal__c record there can be one or many Matter__c records.
I created a Trigger below but it is not working. I believe the trigger does not have coding that will place the currency values in the Total_Fees__c field in Matter__c records to be summarize in the Engagement_Total_Fees__c in the Deal__c record.
I am not an expert in triggers and I could appreciate the help.
trigger UpdateEngagementTotalFees on Matter__c (After insert,After update,After delete){
Set<String>dealIds= new Set<String>();
if(Trigger.isDelete){
for(Matter__c mat : Trigger.old){
dealIds.add(mat.Deal__c);
}
}else if(Trigger.isUpdate){
for(Matter__c mat : Trigger.New){
if(mat.Deal__c != trigger.oldMap.get(mat.id).Deal__c || mat.Total_Fees__c !=trigger.oldMap.get(mat.id).Total_Fees__c){
if(mat.Deal__c!=null)
dealIds.add(mat.Deal__c);
if(trigger.oldMap.get(mat.id).Deal__c!=null)
dealIds.add(trigger.oldMap.get(mat.id).Deal__c);
}
}
}else{
for(Matter__c mat : Trigger.New){
if(mat.Deal__c != null){
dealIds.add(mat.Deal__c);
}
}
}
if(dealIds.size()>0){
TriggerUtility.rollupBookValues(dealIds,'Matter__c');
}
}
Probably the real work is happening in the TriggerUtility.rollupBookValues() method.