function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
Can any one provide a sample code to perform the Rollup Sum() Trigger.
Aggregate functions allow you to roll up and summarize your data for analysis
Try the below code snippet as reference
trigger DealTrigger on DealInterest__c (before update,before insert){
DealInterest__c di;Deal__c dd;AggregateResult[] lid;String str;
for(DealInterest__c d:Trigger.New){dd=[Select Name From Deal__c where id=:d.DealL__c ];lid=[Select sum(DealNum__c)num from DealInterest__c where DealL__c=:d.DealL__c ];if(lid[0].get('num')==null){d.DealNum__c=1;d.IntID__c=d.DealL__c+'-000'+String.valueof(1);
}}}
For more detail follow the below linkhttp://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_agg_functions.htm
Why you want to it from Trigger, you van jsut create a roll up summery field.
Any how if you wnat to do it from trigger
then use
List<AggregateResult> aggResult= [Select sum(field name) <alias o filed> From Object WHERE field_name=:?];
Hi,
Aggregate functions allow you to roll up and summarize your data for analysis
Try the below code snippet as reference
trigger DealTrigger on DealInterest__c (before update,before insert)
{
DealInterest__c di;
Deal__c dd;
AggregateResult[] lid;
String str;
for(DealInterest__c d:Trigger.New)
{
dd=[Select Name From Deal__c where id=:d.DealL__c ];
lid=[Select sum(DealNum__c)num from DealInterest__c where DealL__c=:d.DealL__c ];
if(lid[0].get('num')==null)
{
d.DealNum__c=1;
d.IntID__c=d.DealL__c+'-000'+String.valueof(1);
}
}
}
For more detail follow the below link
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_agg_functions.htm
Why you want to it from Trigger, you van jsut create a roll up summery field.
Any how if you wnat to do it from trigger
then use
List<AggregateResult> aggResult= [Select sum(field name) <alias o filed> From Object WHERE field_name=:?];