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
StenderStender 

Quick question on referncing a field

Hello,

 

I think this will be a really quick question/answer.  I have a class that is running a bunch of checks on an object while also looking for a bunch of other objects, kinda complex to describe quickly.  Anyhow as one point a List<Sold_Accounts__c>  (which is a custom object) is passed into a method that looks at fields on related (parent) records.  But those fields are returning as 'null' when I run tests (I am POSITIVE that the fields are populated when testing).  I know there is a simple way to get those fields, but for the life of me I can't remember how.  Here is the relevant bit of code:

	public static void createPDsandLITs(List<Sold_Accounts__c> sAs){
/* will end up with three lists:  soldAccountsToUpdate (this will be all that need to be updated with the PD id), pdsToBeCreated (this is a Map that we will use to create and PDs necessary and then insert their new ID into the corresponding sold Account record), and pdsToUpate (this will be BOTH PDs that need to have their billing action req'd filed updated as well as ones that need their vendor/interface fields updated) */
		
		//There are several scenarios that need to be handled, depending on the selection in the 'Billing Process' field on the P/S record.  A PD may need to be created, a LIT may need to be created
		//below are several variables that will handle these scenarios, which will all eventually be either 'discarded' or put into three lists: Sold Accounts to be updated (i.e. to insert PD record ID), PDs to be inserted(for those that always required a new PD, or those that )
		List<Sold_Accounts__c> checkForPD = new List<Sold_Accounts__c>();
		List<Sold_Accounts__c> saNeedsToCreatePD = new List<Sold_Accounts__c>();							
		//this Map<> will be used to hold a connection between a Sold Account (ID) and the PD that needs to be inserted.  This will allow us to easily add the PD's ID to the corresponding SA after insertion(creation) without having to find it (meaning less SOQL queries and therefore less chance of DML limits being hit)
		Map<ID, Participation_Detail__c> pdsToBeCreated = new Map<ID, Participation_Detail__c>();
		//this list will be a list of ALL SAs that need to have either an existing or newly created PD ID added to them, meaning the SA will then need to be updated
		List<Sold_Accounts__c> soldAccountsToUpdate = new List<Sold_Accounts__c>();		
		
		//Intermediate checks to see which 'category' each SA falls into (depending on selection made for Billing Process on P/S record).  They are added to appropriate lists and the PDs will be added later.
		
		For(Sold_Accounts__c currentSA :sAs){
			system.debug('*****************************************************--->  Current SAs PS:  ' + currentSA.Opportunity_Product_Record__r.Product_Service__c);
			system.debug('*****************************************************--->  Current SAs PS Billing Process:  ' + currentSA.Opportunity_Product_Record__r.Product_Service__r.Billing_Process__c);			
			If(currentSA.Opportunity_Product_Record__r.Product_Service__r.Billing_Process__c == 'Participation Details (PD) Only'){
				saNeedsToCreatePD.add(currentSA);				
			}
			If(currentSA.Opportunity_Product_Record__r.Product_Service__r.Billing_Process__c == 'PD and then Line Item/Subsequent Billing Tasks'){
				checkforPD.add(currentSA);
			}

******code continues*******

 

 

The debugs are coming out as null, which is incorrect.  What am I doing wrong and/or how can I easily fix this?

 

Thanks in advance for any help.

 

Jeremy Stender