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
diydiy 

__r is not working

Asset - Assetid,serialnumber and qty

transaction - tno , Asset(fk)


I want to relate to transaction (Asset) to Asset(serialnumber)


public List<Asset> Incemp {get;set;}   ---> I m not using list<> =new list<> , because i added a row...

  temp = Incemp.Asset__c - working fine

  temp = Incemp.Asset__r.serialnumber__c - not working


Any idea...
Ashish_SFDCAshish_SFDC
Hi Diya, 

Its like SObject__r.SObject2__r.Fieldname__c where the primary object is the SObject and the related Object is the SObject2. 

See the link below for further information. 

http://developer.force.com/cookbook/recipe/displaying-fields-from-a-related-record-on-a-detail-page

Regards,
Ashish
srinu_SFDCsrinu_SFDC
Hi Diya,

       You need to retrieve the field on the related object to refer it.
        This might help you: List<Asset> lncemp = [select tno, Asset__r.serialnumber__c from Asset];
       
 

Thanks,
Y.Srinivas
diydiy
hi srinivas,

    Actually (public List<Asset> Incemp {get;set;}) using reason is  i added a row one bye one..
srinu_SFDCsrinu_SFDC
Not sure I get your concern completely, but this might help:


for(Asset lncemp : [select tno, Asset__r.serialnumber__c from Asset]){
   temp = Incemp.Asset__r.serialnumber__c
}


Thanks,
Y.Srinivas
Ashish_SFDCAshish_SFDC
Hi Diya,

If the suggestion posted by Srinivas does not work can you paste the whole code block so that we can understand properly.

i would like to know the object name on which the trigger is written, how is the other object related and what is the field (Type and name).

Regards,
Ashish