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 

accessing the relationship object field value in apex trigger handler ?

Hi Everyone - I am trying to get the field value of relationhip object and putting in the set though it is not throwing any error but when i try to do system.debug it returns null value. when i tried to do query it returns value. below is my code can some one suggest is my approach is correct or somehwhere i am going wrong?

 Set<String> assetCouponCodes = new Set<String>();
set<id>newOrderItemId = new set<id>();
for (Asset asset : newAssetList) {
            assetCouponCodes.add(asset.Order_Product__r.DISCOCouponCode__c);
             system.debug('assetCouponCodes' +assetCouponCodes);
newOrderItemId.add(asset.Order_Product__r.id);
             system.debug('newOrderItemId' +newOrderItemId);

Thanks!
AnkaiahAnkaiah (Salesforce Developers) 
Hi John,

Can you please check the newAssetList getting the value for Order_Product__r.DISCOCouponCode__c

Thanks!!
JohnDuraiJohnDurai
@Ankaiah  - Yes it is returning, but i am trying to access the field value of lookup object from child object (i.e Order_Product__r.DISCOCouponCode__c) which is not retuning any other way to fecth this value?