function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pavan mithunpavan mithun 

Hi All, how to Write a trigger on opportunity so that it should roll-up Opp field Values Only for particular Record Type (Say Record Type A not for Record Type B) using LREngine

Prithviraj_ChavanPrithviraj_Chavan
Hi Pavan,
RecordType recordType = [ SELECT ID FROM RecordType Where Name = ' RecordType Name'  LIMIT 1 ];
AggregateResult[] groupedResults
  = [SELECT CampaignId, AVG(Amount)
      FROM Opportunity
      GROUP BY CampaignId WHERE RecordTypeId = :recordType.Id ];
for (AggregateResult ar : groupedResults)  {    
	System.debug('Average amount' + ar.get('expr0'));
}