You need to sign in to do that
Don't have an account?
Jyosi jyosi
Bulkfying the trigger code
Hello Everyone.
I have created a trigger by using context varibale.Need to bulkfying my code.
Can you please help out.
trigger AccountTestTrigeer on Account (before insert, before update) {
AccountTestTrigeerhandler handler = new AccountTestTrigeerhandler();
if(Trigger.Isbefore && Trigger.isInsert)
{
handler.onDuplicateCheck(Trigger.New);
}else if (Trigger.Isbefore && Trigger.Isupdate)
{
handler.onDuplicateCheck(Trigger.New);
}
}
And here is my Trigger Handler class
public without sharing class AccountTestTrigeerhandler
{
public void onDuplicateCheck(List<Account> Acctlist)
{
for(Account acterror:Acctlist)
{
List<Account> acc=[Select id from Account where Name=:acterror.Name ]; //Need to query this outside the for lOOP who to Acheive this please
system.debug('AccountistVaues' +acc);
system.debug('AccountSize@@@@@@@@@@@'+acc.size());
if(acc.size()>0)
{
acterror.addError('You Cannot Create the Duplicate Account');
}
}
}
}
Regards,
Jyo
I have created a trigger by using context varibale.Need to bulkfying my code.
Can you please help out.
trigger AccountTestTrigeer on Account (before insert, before update) {
AccountTestTrigeerhandler handler = new AccountTestTrigeerhandler();
if(Trigger.Isbefore && Trigger.isInsert)
{
handler.onDuplicateCheck(Trigger.New);
}else if (Trigger.Isbefore && Trigger.Isupdate)
{
handler.onDuplicateCheck(Trigger.New);
}
}
And here is my Trigger Handler class
public without sharing class AccountTestTrigeerhandler
{
public void onDuplicateCheck(List<Account> Acctlist)
{
for(Account acterror:Acctlist)
{
List<Account> acc=[Select id from Account where Name=:acterror.Name ]; //Need to query this outside the for lOOP who to Acheive this please
system.debug('AccountistVaues' +acc);
system.debug('AccountSize@@@@@@@@@@@'+acc.size());
if(acc.size()>0)
{
acterror.addError('You Cannot Create the Duplicate Account');
}
}
}
}
Regards,
Jyo
PS: if this answers your question then hit Like and mark it as solution!
All Answers
PS: if this answers your question then hit Like and mark it as solution!
Thanks a lot,Need some help for bettering undertstanding when to use sets ,List and Maps,
Is there any Link/document with you.
That would be great help .
Regards,
jyo