You need to sign in to do that
Don't have an account?
trigger for update child data on parent record...?
Parent Object - Account there are two field Total_opp__c and Total_revenue__C
(Lookup relationship)
Child object - Opportunity - field Revenue__C
i want sum of revenue on account record (in field Total_Revenue__C ) page as opportunities associated with it
and in th Total_Opp__C it should show count of opportunities like how many opportunities available in that
please help to complete below trigger...
trigger update_opp_detail on Opportunity (After insert, After update,After delete, After undelete) {
set<id> oppSet = new set<id>();
for (opportunity op : trigger.new) {
opSet.Add(op.AccountId);
}
Thank you
(Lookup relationship)
Child object - Opportunity - field Revenue__C
i want sum of revenue on account record (in field Total_Revenue__C ) page as opportunities associated with it
and in th Total_Opp__C it should show count of opportunities like how many opportunities available in that
please help to complete below trigger...
trigger update_opp_detail on Opportunity (After insert, After update,After delete, After undelete) {
set<id> oppSet = new set<id>();
for (opportunity op : trigger.new) {
opSet.Add(op.AccountId);
}
Thank you
Example On account update from contact
trigger Updatefee on Contact (After insert, After update, After delete ) {
Set<Id>setIds = new Set<Id>();
List<Account>lstacc = new List<Account>();
if(trigger.isinsert==true){
For(Contact objcon : trigger.new){
setIds.add(objcon.AccountId);
}
List<Account>lstacc1 = [Select id,name,count__c,Total_fee__c,(Select id,name,Fee__c from Contacts) from Account where Id IN:setIds];
If(lstacc1 !=null && lstacc1.size()>0 ){
For(Account acc : lstacc1){
For(Contact con : trigger.new){
if(Con.AccountId == acc.Id ){
if(acc.Total_fee__c == null){
acc.Total_fee__c = 0;
}
acc.Total_fee__c = acc.Total_fee__c + Con.Fee__c;
}
acc.count__c = lstacc1[0].Contacts.size();
}
lstacc.add(acc);
}
}
}
if(lstacc.size()>0)
update lstacc;
}