You need to sign in to do that
Don't have an account?
sundhar.mks1.3962649227519546E12
how to write the Trigger to following Requirment?
Hi,
On particular Owner have how many of record created by today on "Opportunity" object? That Record count will update to another object of "Service" , How to achive this updatetion Using trigger
NOTE: No relationship "Opportunity" to "Service", this case how to do this?
I have used following code but i'm struggle Kindly give any idea
Code:
============
Public class OpportunityTriggerHandler{
public void OnbeforeInsert(list<Opportunity> listNewOpps){
List<Opportunity> RecordCount=new List<Opportunity>();
AggregateResult[] groupedResults;
groupedResults = [SELECT Name FROM Opportunity WHERE id =:UserInfo.getUserId() group by name];
system.Debug('============'+groupedResults);
}
public void OnbeforeUpdate(Map<Id,Opportunity> newOppMap,Map<Id,Opportunity> oldOppMap){
List<Forecast_Agent__c> Orders = New list<Forecast_Agent__c>([Select Total_Sale__c from Forecast_Agent__c where Owner.Name ='Puthuvannam']);
for(Forecast_Agent__c sale : Orders){}
{
sale.count = Opportunity.Count;
}
Update Orders;
}
}
Thanks.
On particular Owner have how many of record created by today on "Opportunity" object? That Record count will update to another object of "Service" , How to achive this updatetion Using trigger
NOTE: No relationship "Opportunity" to "Service", this case how to do this?
I have used following code but i'm struggle Kindly give any idea
Code:
============
Public class OpportunityTriggerHandler{
public void OnbeforeInsert(list<Opportunity> listNewOpps){
List<Opportunity> RecordCount=new List<Opportunity>();
AggregateResult[] groupedResults;
groupedResults = [SELECT Name FROM Opportunity WHERE id =:UserInfo.getUserId() group by name];
system.Debug('============'+groupedResults);
}
public void OnbeforeUpdate(Map<Id,Opportunity> newOppMap,Map<Id,Opportunity> oldOppMap){
List<Forecast_Agent__c> Orders = New list<Forecast_Agent__c>([Select Total_Sale__c from Forecast_Agent__c where Owner.Name ='Puthuvannam']);
for(Forecast_Agent__c sale : Orders){}
{
sale.count = Opportunity.Count;
}
Update Orders;
}
}
Thanks.
Assuming there is a lookup relationship between User and Service objects, the trigger on the opportunity can save the record count on the User record. Create a formula field on the service object that pulls the count.
Hope this helps.
Thanks,
Sai