You need to sign in to do that
Don't have an account?

trigger failed on insertion of records
Here my scinario is if my Account name is not empty then it should be insert 2 records and current record but insertion is failed.
trigger mergeAccs on Account (after insert) {
list<Account> acs=new list<Account>{new Account(name='mergeAN1'),new Account(name='AnveMerge2')};
for(Account AC:trigger.new){
if(ac.name!=' '){
insert acs;
}
}
}
As I said in my last answer "
"
To do this create a static variable and use it as blocker
All Answers
Try this!
You are forgetting bascis
as per your code now i am getiing a big big big almost 300+ lines of error code i am getting
I am afraid with the scenario you have in which you want to insert 2 more accounts with the current one will lead to recursive "Maximum Trigger depth reached" error.
I would rather suggest you to have a temporary field flag on Account that will be hidden on page layout that will determine whether the 2 new records created are through trigger.
You can create a boolean field that will be set to true for newly created records in trigger as below
trigger mergeAccs on Account(after insert) {
list < Account > acList = new list < Account > ();
for (Account ac: trigger.new) {
if (ac.name != null && ac.insertedThroughTrigger__c ==false) {
//add your new Accounts here
Account a1 = new Account(name='mergeAN1', insertedThroughTrigger__c = true);
Account a2 = new Account(name='AnveMerge2', insertedThroughTrigger__c = true);
acList.add(a1);
acList.add(a2);
}
}
insert acList;
}
As I said in my last answer "
"
To do this create a static variable and use it as blocker
Whenever we write trigger on an object with a particular event and apply same DML in that trigger then it launch cyclic trigger thread so in order to avoid it static variables is best way to use as expalined above. much appriciate this way.
My Dear Thank you for your valueble information i am new for salesforce.......
any way how we can access the class in the trigger....because i got error like this
"Variable does not exist: RecusrsiveBlocker.isBlocked at line 2 column 8"
RecusrsiveBlocker is not same as the class name RecursiveBlocker