You need to sign in to do that
Don't have an account?
Indian
Trigger to Update Rollup summary fields.
Hi everyone,
i have a trigger to update the rollup summary field on master record. when i was trying to update one field. its working correctly.
here is the problem, when i was trying to update more than one field with based on the Amount field and the critiria is different. i have around 8 fields to update.
here is the code for u r reference
help is needed urgently
You could use following, in your query but this will not work with other criteria,
NOT(FirstName like '%V%') ( as per my understanding NOT filter like this one can't be used with other filters)
what you can do it, first get the result using opportunity filter as it is then have loop around result set and filter data within that loop on firstname and create another list.
base line is , filter firstname data in program; after fetching data in your query.
All Answers
here is the code
trigger OpportunityRollUpPayments on Payment__c (after delete, after insert, after update) {
set<Id> OpportunityIds = new set<Id>();
if(trigger.isInsert || trigger.isUpdate){
for(Payment__c p : trigger.new)
{OpportunityIds.add(p.Opportunity__c);}}
if(trigger.isDelete){
for(Payment__c p : trigger.old){
OpportunityIds.add(p.Opportunity__c);}}
map<Id,Double> OpportunityMap = new map <Id,Double>();
for(AggregateResult q : [select Opportunity__c,sum(Amount__c)from Payment__c where Opportunity__c IN :OpportunityIds group byOpportunity__c]){
OpportunityMap.put((Id)q.get('Opportunity__c'),(Double)q.get('expr0'));
}
List<Opportunity> OpportunitiesToUpdate = new List<Opportunity>();
for(Opportunity o : [Select Id, Total_Payments__c from Opportunity where IdIN :OpportunityIds]){
Double PaymentSum = OpportunityMap.get(o.Id);
o.Total_Payments__c = PaymentSum;
OpportunitiesToUpdate.add(o);
}
update OpportunitiesToUpdate;
}
what is the exact error?
i need to addd the filter criteria in the select statement.
for(AggregateResult q : [select Opportunity__c,sum(Amount__c)from Payment__c where Opportunity__c IN :OpportunityIds group byOpportunity__c])
in this statement i need to put criteria "First Name Does not contains TR".
can you help me out this issue.
You could use following, in your query but this will not work with other criteria,
NOT(FirstName like '%V%') ( as per my understanding NOT filter like this one can't be used with other filters)
what you can do it, first get the result using opportunity filter as it is then have loop around result set and filter data within that loop on firstname and create another list.
base line is , filter firstname data in program; after fetching data in your query.