You need to sign in to do that
Don't have an account?

formula in test method
Hi Guys,
For some reason, All my the formula value are null in my APEX test method, but works all right if I manually insert some data from user interface. Is it normal?
But I really need some formula value for the query condition of APEX SOQL.
Thanks in advance
After you insert/update an object in test class for which you need to access its formula, you will need to query to get the value of the formula, something like this:
Here, testDate__c is a formula field based on the Date__c field, the first debug statement shows null, the second one shows the set value of the formula.
All Answers
After you insert/update an object in test class for which you need to access its formula, you will need to query to get the value of the formula, something like this:
Here, testDate__c is a formula field based on the Date__c field, the first debug statement shows null, the second one shows the set value of the formula.
thanks, it works perfect. :)
Hi
I've got the same problem, with the difference that I can't run the insert() prior to updating the formula field, because a validation rule answers false. This validation rule answers false because value of formula field is null…
And also, to run the trigger (on insert…), I definitely need to have a value different from null.
Bit of a snake biting its own tail…