You need to sign in to do that
Don't have an account?

How to get Max Number Incase of Insert & Delete Operation
Below Code Is Working For Insert Operation, Now I Need Max Number In the Case of Delete Operation How Can Get?
trigger SkillGroup_With_High_Rank on Skill_Group__c (after insert,before delete) {
List<Id> AccnId = New List<Id>();
public String Maxno;
for(Skill_Group__c sk:Trigger.New){
AccnId.add(sk.Account_Name__c);
system.debug('Accountssss'+AccnId);
}
list<aggregateResult> aggResults = [Select Max(Rank__c)RA from Skill_Group__c Where Account_Name__c In:AccnId ];
system.debug('@@@@@@'+aggResults[0].get('RA'));
Maxno = string.valueOf(aggResults[0].get('RA'));
system.debug('$$$$$$$'+Maxno);
for(Account ac: [Select id,Skill__c from Account where id In:AccnId]){
ac.Skill__c = Maxno;
}
}
trigger SkillGroup_With_High_Rank on Skill_Group__c (after insert,before delete) {
List<Id> AccnId = New List<Id>();
public String Maxno;
for(Skill_Group__c sk:Trigger.New){
AccnId.add(sk.Account_Name__c);
system.debug('Accountssss'+AccnId);
}
list<aggregateResult> aggResults = [Select Max(Rank__c)RA from Skill_Group__c Where Account_Name__c In:AccnId ];
system.debug('@@@@@@'+aggResults[0].get('RA'));
Maxno = string.valueOf(aggResults[0].get('RA'));
system.debug('$$$$$$$'+Maxno);
for(Account ac: [Select id,Skill__c from Account where id In:AccnId]){
ac.Skill__c = Maxno;
}
}
Use one list, then populate it baed on what trigger type you are running: