You need to sign in to do that
Don't have an account?
mustapha L 1
FOR loops iteration
Hi All
i'm doing the following:
trigger AutoCreateMaint on QuoteLineItem (before insert) {
for (QuoteLineItem quoteli : Trigger.new){
Boolean IsMaintenance = False;
//check if the product has Ismaintenance box Checked
IsMaintenance = [OSQL request]
if (isMaintenance)
{Process}
}
}
I have a Problem with the FOR loop which is supposed to run ONCE but always run twice...of course the second time it runs the OSQL query fails and tigger fails !
i do not undesrtand reason why the LOOP run twice ?
to try to fix it, i have added a "break" but even like this the LOOP runs twice instead to exit
this is what i have each time it runs the second iteration:
"17:46:35:086 FATAL_ERROR System.QueryException: List has no rows for assignment to SObject"
could you assist please?
Many thanks
i'm doing the following:
trigger AutoCreateMaint on QuoteLineItem (before insert) {
for (QuoteLineItem quoteli : Trigger.new){
Boolean IsMaintenance = False;
//check if the product has Ismaintenance box Checked
IsMaintenance = [OSQL request]
if (isMaintenance)
{Process}
}
}
I have a Problem with the FOR loop which is supposed to run ONCE but always run twice...of course the second time it runs the OSQL query fails and tigger fails !
i do not undesrtand reason why the LOOP run twice ?
to try to fix it, i have added a "break" but even like this the LOOP runs twice instead to exit
this is what i have each time it runs the second iteration:
"17:46:35:086 FATAL_ERROR System.QueryException: List has no rows for assignment to SObject"
could you assist please?
Many thanks
http://amitsalesforce.blogspot.in/2015/03/how-to-stop-recursive-trigger-in.html
You can create a class with a static Boolean variable with default value true. In the trigger, before executing your code keep a check that the variable is true or not. Once you check make the variable false.
Apex Class with Static Variable
Then update your trigger like below
Please let us know if this iwll help you,
Thanks,
Amit Chaudhary
All Answers
http://amitsalesforce.blogspot.in/2015/03/how-to-stop-recursive-trigger-in.html
You can create a class with a static Boolean variable with default value true. In the trigger, before executing your code keep a check that the variable is true or not. Once you check make the variable false.
Apex Class with Static Variable
Then update your trigger like below
Please let us know if this iwll help you,
Thanks,
Amit Chaudhary