I created three formula fields on a custom object.
- Formula(Date) references parent objects
- Formula(Time) references parent objects
- Formula(DateTime) references formula field 1 & 2.
When I query for these fields using SOQL, field 1 & 2 return their value. Field 3 returns NULL. If I open up the record, there is a value in the field.
Does anyone know why this is happening or what I can do to fix it?
I have tried using
Formula.recalculateFormulas(). When I performed this on a list i received an 'Unexpected Exception'.
When I called
recalculateFormulas() on a single Object in the list, the value was now a valid date time (not null)
See the following code snippet:
List<cust)obj__c> listCustomObj = [Select Id, Formula1__c, Formula3__c FROM cust_obj__c]; system.debug(listCustomObj.Formula3__c) //null //List<FormulaRecalcResult> results = Formula.recalculateFormulas(listCustomObj); //throws unexpected exception listCustomObj.recalculateFormulas(); System.debug(listCustomObj.Formula3__c) //correct value
My questions are:
- Why is the initial query returning null instead of the calculated value?
- Why does the recalculateFormulas() method fail when called on a list?
- Any way you can recommend (without changing my formula fields) that I can solve this?