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
John SamuelsJohn Samuels 

Attempting to extract data from a related field, but not using normal query structure

Hello,

I have a custom object (call it Object XYZ) and the normal Account object. I have a button that is supposed to draw information from fields in both Object XYZ and Account. The button is within Object XYZ.

Drawing info from fields in Object XYZ is no problem. For example:
xmldata += xmlField{!YIP__Object_XYZ__c.Name}
would extract all information within the 'Name' field in Object XYZ (with some minor tweaks).

However, I also want to try and draw info from fields in the Account object. I am having trouble. First I tried variations of
xmldata += xmlField{!YIP__Object_XYZ__c.Name.Account.Phone}
which I think was way off. Next I dug through the forums and tried
xmldata += xmlField{!YIP__Object_XYZ__c.YIP__Link__r.Phone}
where 'Link' is the name of the relationship between the two objects. Now I am stumped, mainly because other questions askers usually use a more traditional format (SELECT, WHERE, etc). Am I missing something obvious? Thanks


bob_buzzardbob_buzzard
Your third snippet is the correct notation - the only thing I can think of is that the Link__c field is something added outside of the namespace (e.g. a locally added field after a managed package has been installed).  Try the following:

xmldata += xmlField{!YIP__Object_XYZ__c.Link__r.Phone}





John SamuelsJohn Samuels
xmldata += xmlField{Account.Phone} ended up working. Salesforce found the path by itself.