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
Josephine ButJosephine But 

How to get the name of the reference?

Hi,
  I have the following statement I want to do  the testing, System.assertEquals('Kitchen Cabinet',stockX[0].product__c );

stockX[0].product__c is a reference( a lookup field to the product), how can I get the name of the product instead of getting the reference??

Thanks,
    Jo
Ajay choudharyAjay choudhary
Hi Josephine,

You can use stockX[0].product__r.Name to reference the name field from product.

Thanks.
Josephine ButJosephine But
It is not working, the stockx[0].product__r.Name return nothing. I use system.debug to print it out, it prints nothing, not a null.