You need to sign in to do that
Don't have an account?
sfdc integrator.ax1790
remove a record from trigger.new list
Hi,
When i insert 10 records if any of the record is not equal to Utility.AccountRecordType then i need to remove the record from the trigger.new list.
for(integer i=0;i<Trigger.new.size();i++){
if(Trigger.new[i].RecordTypeId != Utility.AccountRecordType){
Trigger.new.remove(i);
}
}
Regards
Suresh S
When i insert 10 records if any of the record is not equal to Utility.AccountRecordType then i need to remove the record from the trigger.new list.
for(integer i=0;i<Trigger.new.size();i++){
if(Trigger.new[i].RecordTypeId != Utility.AccountRecordType){
Trigger.new.remove(i);
}
}
Regards
Suresh S
you can't do that and remove from Trigger.new,
you can do the below :
1- add after insert trigger and put the accounts that have a recordtype different then Utility.AccountRecordType and delete them ex:
list<Account> listAccDel= new list<Account>();
for(integer i=0;i<Trigger.new.size();i++)
{
if(Trigger.new[i].RecordTypeId != Utility.AccountRecordType)
{
listAccDel.add(Trigger.new[i]);
}
}
delete listAccDel;
Good luck
you can refer below code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
You can't delete a record before it's been inserted.