+ Start a Discussion
lainchburylainchbury 

Is a change of value in a formula field an UPDATE event?

Hi

 

I'm trying to create a trigger that fires when a formula field is updated.

 

My question is whether a formula field updating automatically (without the user entering the record and editing or saving) constitutes an UPDATE event that could fire a trigger?

 

Thanks,

 

Paul

Best Answer chosen by Admin (Salesforce Developers) 
GuyClairboisGuyClairbois

Hi Paul,

 

This depends on what's in the formula.

 

I'm assuming that the formula field is either time-based or fetching some fields from other objects. (If not, then the formula will automatically get updated upon you querying if from the trigger after any update on the record itself).

 

In case 1, you could consider scheduling a time-based trigger at the time the object is created/updated. The execution moment for the time-based trigger would be the moment the formula result changes (assuming that you can predict that).

 

In case 2, you will have to base your trigger on the formula source field(s), so build a trigger on the other related object.

 

 

All Answers

bob_buzzardbob_buzzard

Formula fields won't cause triggers to fire I'm afraid.  AFAIR they are populated when they are retrieved from the database, rather than having values written to them every time.

 

Bramha1Bramha1

Hi,

 

   Tha formula field will be updated automatically during both insert and update.

 

 

Cheers

 

Bramha

GuyClairboisGuyClairbois

Hi Paul,

 

This depends on what's in the formula.

 

I'm assuming that the formula field is either time-based or fetching some fields from other objects. (If not, then the formula will automatically get updated upon you querying if from the trigger after any update on the record itself).

 

In case 1, you could consider scheduling a time-based trigger at the time the object is created/updated. The execution moment for the time-based trigger would be the moment the formula result changes (assuming that you can predict that).

 

In case 2, you will have to base your trigger on the formula source field(s), so build a trigger on the other related object.

 

 

This was selected as the best answer
santosh duvvurisantosh duvvuri

Hi

 

Formula field wont contain any values by it self. They will fetch the values every time we access them. As such there is no value stored in the field, so there will no trigger fired.

 

Instead you can write a trigger on change of the fields you are referring to in the formula.

 

Thanks & Regards

Santosh

lainchburylainchbury

Thanks for your help guys, I get it now.

 

Paul