Skip to main content
added 590 characters in body
Source Link
IllusiveBrian
  • 4.3k
  • 1
  • 16
  • 23

You can use (what I call) a blank update to force database rules to run on an object:

trigger CreditRequestTrigger on Credit_Request__c(after update)
{
    update [select ID from Credit_Lines__c where Credit_Request__c in :Trigger.New];
}

As Derek F pointed out in comments, you should be careful when updating another object in a trigger in general, as you can cause recursion between the two objects if they can update each other. This is very easy to do with Master-Detail records, since roll-up fields cause an update to the parent, so if you update something in Credit_Lines__c which is part of a roll-up field on Credit_Request__c, you will end up calling your Credit_Request__c trigger again. You can prevent this using static variables, which will retain their value throughout the entire database transaction.

You can use (what I call) a blank update to force database rules to run on an object:

trigger CreditRequestTrigger on Credit_Request__c(after update)
{
    update [select ID from Credit_Lines__c where Credit_Request__c in :Trigger.New];
}

You can use (what I call) a blank update to force database rules to run on an object:

trigger CreditRequestTrigger on Credit_Request__c(after update)
{
    update [select ID from Credit_Lines__c where Credit_Request__c in :Trigger.New];
}

As Derek F pointed out in comments, you should be careful when updating another object in a trigger in general, as you can cause recursion between the two objects if they can update each other. This is very easy to do with Master-Detail records, since roll-up fields cause an update to the parent, so if you update something in Credit_Lines__c which is part of a roll-up field on Credit_Request__c, you will end up calling your Credit_Request__c trigger again. You can prevent this using static variables, which will retain their value throughout the entire database transaction.

Source Link
IllusiveBrian
  • 4.3k
  • 1
  • 16
  • 23

You can use (what I call) a blank update to force database rules to run on an object:

trigger CreditRequestTrigger on Credit_Request__c(after update)
{
    update [select ID from Credit_Lines__c where Credit_Request__c in :Trigger.New];
}