6

Winter 20 release is in live, so I wanted to use this glorious feature Formula.recalculateFormulas

Thus I tried the below block of code:

Opportunity opp = new Opportunity(Purchase_Price__c=2000 , StageName='Underwriting' ,Acquisition_Channel__c ='Direct to Consumer');
List<FormulaRecalcResult> frc =Formula.recalculateFormulas(new List<Opportunity>{opp});
System.debug(frc);

To my surprise, the below piece of code produces gack

Error on line 10, column 1: System.UnexpectedException: Salesforce System Error: 1845503703-144759 (548651819) (548651819) Class.System.Formula.recalculateFormulas: line 10, column 1

Whereas the standard SObject recalculateFormulas works

Opportunity opp = new Opportunity(Purchase_Price__c=2000 , StageName='Underwriting' ,Acquisition_Channel__c ='Direct to Consumer' );
opp.recalculateFormulas();    
System.debug(opp.Total_Finance_Amount__c); //Prints 2000

The doc doesn't say that this is beta, has anyone faced this issue and managed to fix it?

  • any cross-object formulas? – cropredy Oct 22 '19 at 20:52
  • @cropredy yes a lot of.... it’s a 200column table with 10+ cross object formulas – Pranay Jaiswal Oct 22 '19 at 20:55
  • 2
    try adding the relationship fields in the first example and see what happens. The sobject version of recalculateFormulas blew up if relationship fields existed; perhaps Formula is the opposite? – cropredy Oct 22 '19 at 21:01
  • @cropredy that might be it... I have raised a case to confirm this. – Pranay Jaiswal Oct 24 '19 at 18:43
  • 2
    @PranayJaiswal was this ever confirmed as a fix? I'm getting the same error now. – George Albrecht Apr 6 at 16:56

Your Answer

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

Browse other questions tagged or ask your own question.