You need to sign in to do that
Don't have an account?
Zoren Domingo
apex trigger delete multiple record
Hi, can anyone help me creating apex trigger for deleting multiple records once a custom field is updated?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
I trust you are doing very well.
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
*Instead of Name you can take any custom field in if condition*
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Here we are looping the list of accounts that are updated and check a condition for field update.If the update matches the condition then we are deleting the record.
Hope this Helps.
Thanks
Hi I forgot to mention,
the field that will be check is on the OpportunityLineItem
the record to be create is on another custom object related to opportunity
OpportunityLineItem >> Opportunity << Custom_object__c
Please use below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Below code can fullfill your requirements. Hope this will work for you.
trigger DeleteOpp on Opportunity(after insert, after update){
List<Opportunity> opportunityList = new List<Opportunity>();
for(Opportunity opp: Trigger.new){
if(opp.name__c == 'abc')
{
opportunityList.add(acc);
}
}
if(opportunityList.size()>0)
{
delete opportunityList;
}
}
Please mark this as best answer if this solves your problem.
Thank you
Ajay Dubedi