You need to sign in to do that
Don't have an account?
badri nath 9
trigger to chack duplicates i am using query not soql&List?
code below working not fine I am querying the records don't use soql&collections.please find that ,
trigger Trgr_duplicate_check on Account (before insert,before update) {
//List<Account> actList= [select id,name from Account];
string str = 'select id ,Name from Account' ;
for(Account actobj :Trigger.New){
if(Trigger.isinsert || Trigger.isBefore){
// for(Account actobj1 :actList){
/*if(actobj1.Name == actobj.Name){
actobj.Name.addError('Name already exits!!!');
}*/
if(str.contains(actobj.Name)){ // here require proper method to search strings for duplicates
actobj.Name.addError('Name already exits!!!');
}
// }
}
}
}
Thanks):-
trigger Trgr_duplicate_check on Account (before insert,before update) {
//List<Account> actList= [select id,name from Account];
string str = 'select id ,Name from Account' ;
for(Account actobj :Trigger.New){
if(Trigger.isinsert || Trigger.isBefore){
// for(Account actobj1 :actList){
/*if(actobj1.Name == actobj.Name){
actobj.Name.addError('Name already exits!!!');
}*/
if(str.contains(actobj.Name)){ // here require proper method to search strings for duplicates
actobj.Name.addError('Name already exits!!!');
}
// }
}
}
}
Thanks):-
We need to take an account of three difference conditions such as Before Insert, Before Update, After UnDelete.
Below, trigger handles them.
Trigger Code:
Hope it helps and if it solves the query then please mark it as Best Answer!
i wanted to work with nearly 5MLN Records ., and names are stored in string variable and i wanted to check those,
#Please go through question once,