function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JohnDuraiJohnDurai 

Getting Null value in Formula field Test class

Hi - I have one formula field (PackageDefCode) in Asset object which is getting the value from lookup object (this is the formula Rate_Code__r.Package_Definition_Code__c)

In my test class, I am trying to populate the valud for PackageDefCode in Asset object by inserting lookup record with value but in Asset recrod value shows NULL in test class. is ther any soluiton ?

 
AnkaiahAnkaiah (Salesforce Developers) 
Hi John,

No need to keep the test data for formula field.
insert the test data for Rate_Code__c object in the test class

If this helps please mark it as best answer.

Thanks!!
JohnDuraiJohnDurai
Hi @Ankaiah - I inserted data for Rate code but this formula field is picking the value and shows NULL when i tried to debug rate code has value but only in asset is NULL so could not pass into if conditon and cover the code, I want to understand why Asset field is taking NULL