A recursive trigger is one that will end up calling itself again. For example, if you have a trigger on accounts that updates contacts, and a trigger on contacts that updates accounts, it is possible that the account update could update contacts that would in turn update the account... this will cause errors. The specific solution to this depends on the situation, but usually it will suffice to have a "trigger guard" that will keep the trigger from running a second time. It can look like this:
<pre> public class TriggerGuard { public static boolean accountguard, contactguard; static { accountguard = contactguard = false; } } </pre>
A recursive trigger is one that will end up calling itself again. For example, if you have a trigger on accounts that updates contacts, and a trigger on contacts that updates accounts, it is possible that the account update could update contacts that would in turn update the account... this will cause errors. The specific solution to this depends on the situation, but usually it will suffice to have a "trigger guard" that will keep the trigger from running a second time. It can look like this:
<pre> public class TriggerGuard { public static boolean accountguard, contactguard; static { accountguard = contactguard = false; } } </pre>
A recursive trigger is one that will end up calling itself again. For example, if you have a trigger on accounts that updates contacts, and a trigger on contacts that updates accounts, it is possible that the account update could update contacts that would in turn update the account... this will cause errors. The specific solution to this depends on the situation, but usually it will suffice to have a "trigger guard" that will keep the trigger from running a second time. It can look like this:
<pre>
public class TriggerGuard {
public static boolean accountguard, contactguard;
static {
accountguard = contactguard = false;
}
}
</pre>
-------------------------------------------------------------------------------
<pre>
trigger upAcc on account (after update) {
if(!TriggerGuard.ContactGuard) {
TriggerGuard.AccountGuard = true;
// update the contacts.
}
}
</pre>
--------------------------------------------------------------------------------------
<pre>
trigger upCon on Contact (after update) {
if(!TriggerGuard.AccountGuard) {
TriggerGuard.ContactGuard = true;
// Do something to update the accounts.
}
}
</pre>
In this manner, each trigger advises the other if it is already in progress, thus preventing a recursive call that will ultimately fail.
Thanks,
Allways Cool
All Answers
A recursive trigger is one that will end up calling itself again. For example, if you have a trigger on accounts that updates contacts, and a trigger on contacts that updates accounts, it is possible that the account update could update contacts that would in turn update the account... this will cause errors. The specific solution to this depends on the situation, but usually it will suffice to have a "trigger guard" that will keep the trigger from running a second time. It can look like this:
<pre>
public class TriggerGuard {
public static boolean accountguard, contactguard;
static {
accountguard = contactguard = false;
}
}
</pre>
-------------------------------------------------------------------------------
<pre>
trigger upAcc on account (after update) {
if(!TriggerGuard.ContactGuard) {
TriggerGuard.AccountGuard = true;
// update the contacts.
}
}
</pre>
--------------------------------------------------------------------------------------
<pre>
trigger upCon on Contact (after update) {
if(!TriggerGuard.AccountGuard) {
TriggerGuard.ContactGuard = true;
// Do something to update the accounts.
}
}
</pre>
In this manner, each trigger advises the other if it is already in progress, thus preventing a recursive call that will ultimately fail.
Thanks,
Allways Cool