0

I have a formula field which does some basic calculation. This field has been in the system from the time project went live. As an enhancement there are certain records whose values needs to be corrected - I have a batch class which uses this formula field and a hardcode value needs to be updated for these filtered records. How to do this?

  • Use the data loader to update the fields that the formula uses – Eric Dec 18 '15 at 1:07
  • Are you saying you want the value in the formula field changed? – Nick Cook Dec 18 '15 at 1:10
3

Formula fields are formula fields; they dynamically calculate. You can't smash their values via APEX or Data Loader

However, what you can do is change the formula field to be something like this:

IF(NOT(ISBLANK(myOverrideField__c),
   MyOverrideField__c,  /* apply the override */
   .. the existing formula logic goes here /* use the existing calculation */
)

then, simply update the relevant Sobjects via Data Loader, the UI, or anonymous apex by updating the value of myOverrideValue__c to the value you want the formula field to be.

  • Any easier way is to use the BLANKVALUE() expression. – Nick Cook Dec 18 '15 at 1:59
  • Thanks @NickCook - the idea you gave, I used and it worked. Thanks much – Monika Dec 18 '15 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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