Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two objects called Opportunity and Tournee, with a date field and date field is a formula field which subtracts 10 days from date field in Opportunity and the trigger create events based on this dates and shows them in a calendar. Now, what I found is Tournee trigger is not being called on its date formula field update. Now how do i create Tournee events based on its date field?

share|improve this question
    
Please, share your trigger code so we can see what you've attempted, and why it doesn't work as expected. – smukov 8 hours ago
    
@smukov the code is too big with other functionalities, now all that i want is how to fire a trigger on Cross-Object Formula field update. – Srujan Sujju 8 hours ago
    
a formula field update on it's own is not enough, you need a DML action with it. – Girbot 8 hours ago
3  
Possible duplicate of Formula field change doesn't cause trigger fire – Eric 4 hours ago

Formula fields aren't really being updated per se, but instead, they are just evaluated when you perform a query against the record.

Because of this, if you have two objects A and B, and you have a cross-object formula field on object B that is referencing a field on object A. If you update a record A, you are probably expecting that the record B gets updated as well due to the cross-object formula field, however, this won't be the case. Instead, the record B will calculate the new formula value only when you query for the record, or simply open the record detail page.

Thus, if you want to fire a trigger in this case on object B, the only option you have is to actually create a trigger on object A, query for the related B records inside the object A's trigger, and do whatever you need to do with those records.

share|improve this answer
    
So you want me to replace formula field with trigger ? – Srujan Sujju 7 hours ago
    
No, leave the formula field on Tournee, but you can't use a trigger on that object. You need to create a trigger on Opportunity instead. Then, inside the Opportunity trigger you need to do your thing that you are currently trying to achieve in Tournee trigger. – smukov 7 hours ago
2  
The key thing to understand is that trigger on Tournee object won't be fired when a Date field on Opportunity is updated, because formula fields do not cause a trigger to be fired. You need to use the Opportunity trigger instead to get the related Tournee records and then perform the required logic on them. – smukov 7 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.