
1 risposta
Hi John,I think you want to delete the record once approver Reject .If I am correct then you can achieve this by using below trigger .Only thing is that you need to change the Approval_status Api as per your org and the pick list value for Reject .So your approval action will update that records approval status as rejected then your trigger will collect the record and delete .I have written code for opportunity object you need to replace your object name trigger DeleteRejectedRecord on Opportunity (after update ){
Set<Id>oppIdSet=new Set<Id>();
for(Opportunity opp : Trigger.new ){
if(Trigger.oldMap.get(opp.Id).Approval_Status__c !='Rejected' && opp.Approval_Status__c =='Rejected' ){
oppIdSet.add(opp.Id);
}
}
if(!oppIdSet.isEmpty()){
try{
Delete [SELECT id FROM Oppportunity WHERE Id IN: oppIdSet];
}catch(DmlException de ){
System.debug(de);
}
}
}
Let me know if it helps
Thanks Manoj