You need to sign in to do that
Don't have an account?
santhosh konathala 17
Hi Can anybody do the modification for my Trigger?If we try to update an existing one record in an object I want to delete an rest of the records in an object?But the below code not working fine?
Trigger deloldrecords on Restintegration__c(before update)
{
list<Restintegration__c> newlist= new list<Restintegration__c>();
for(Restintegration__c oldacc:Trigger.old)
{
newlist.add(oldacc);
}
delete newlist;
}
{
list<Restintegration__c> newlist= new list<Restintegration__c>();
for(Restintegration__c oldacc:Trigger.old)
{
newlist.add(oldacc);
}
delete newlist;
}
List<Id> lstId = new List<Id>();
if(trigger.isupdate)
{
for(Restintegration__c res : trigger.new)
{
if(res.id != null)
{
lstId.add(res.id) ;
}
}
}
for(Restintegration__c res: Trigger.old){
List<Restintegration__c > existoppList = [Select Id from Restintegration__c where id in = lstId];
delete existoppList;
}
}
All Answers
santhosh konathala
TRY this coad
but this is not good
trigger checkdelete on Restintegration__c(before update) {
list<Restintegration__c> newlist;
if(trigger.isbefore&&trigger.isupdate){
for(Restintegration__c a:Trigger.old)
{
newlist=[select id,Name from account where id!=:a.id];
}
delete newlist;
}
}
ok
I hope this is help full for u?
Thanks a lot...
The above code working fine..
List<Id> lstId = new List<Id>();
if(trigger.isupdate)
{
for(Restintegration__c res : trigger.new)
{
if(res.id != null)
{
lstId.add(res.id) ;
}
}
}
for(Restintegration__c res: Trigger.old){
List<Restintegration__c > existoppList = [Select Id from Restintegration__c where id in = lstId];
delete existoppList;
}
}