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
kumar palepukumar palepu 

showing null value for afiled when execute in test class for Trigger.

In below code showing site value is null in debug.kindly help us to resolve the issue.
public class testOnUpdation{
static testmethod void Siteupdate()
Account aa = new Account (name='istest',RecordTypeId='012j0000000ogEQAAY',Site='istest');
insert aa;
Account bb= new Account(name='naugh',RecordTypeId='012j0000000qRATAA2',;
insert bb;
system.debug('site';//Here it is showing null value
Account cc=[select Id, name,Site from account where Id =:aa.Id];
cc.Site ='istestchanged' ;
update cc;
update bb;
Christopher McGeeChristopher McGee
I notice that in the line where you declare the Account bb you don't set the site field value:

Account bb= new Account(name='naugh', RecordTypeId='012j0000000qRATAA2',;

So bb.Site would have a null value when you reference it there.
After insert you need to query that inserted record again to get the values from it.

Account BBgetaccnt = [select id,site from account where id =];

kumar palepukumar palepu
@christopher,In test class Self__c is a look up and in trigger i have written code like when we see look up in that lookup record which contains the Site value is automatically populated in the child records once insert the  is working fine by manually doing  but here test class it showing null value.
@ Vj,
I have followed your guidence,but it is showing null value it self
Can you post the trigger code?