You need to sign in to do that
Don't have an account?
JPSeabury
Here's what it looks like when it runs (from a sample Case object):
Message Edited by JPSeabury on 07-28-2008 08:12 PM
Message Edited by JPSeabury on 07-28-2008 08:14 PM
Within a VF page, can I query a related record to the record currently in focus -- without calling Apex class or putting java script in my page?
Here's the code:
Code:
<apex:page standardController="Case"> <!-- Alert Notification Wizard --> <apex:pageBlock title="Send Alert Wizard"> This is an Internal (Cedar Point) <b>Sev {!Case.Priority} ALERT</b> Status Update for the <b>{!Case.Account.Name}</b> Account Team. </apex:PageBlock> <apex:PageBlock title="Current Case Information"> <b>CUSTOMER: </b> {!Case.Account.Name}<br></br> <b>CASE: </b> {!Case.CaseNumber} <br></br> <b>SWITCH:</b> {!Case.Switch__c} <br></br> <b>CATEGORY:</b> {!Case.Category__c} <br></br> <b>OPENED: </b> {!Case.CreatedDate} <p/> <b>SYNOPSIS</b>: {!Case.Subject}<br></br> </apex:pageBlock> </apex>
Here's what it looks like when it runs (from a sample Case object):
Switch__c is a custom field (Lookup relationship to a custom object called Switch), defined within my Case object. Rather than displaying the 18-byte ID of the Switch record, I'd like to display the Switch name.
That was pretty easy to do with the related Account record -- I could use merge field syntax to traverse up the parent child relationship (Case.Account.Name) ... but attempting the same syntax with the Switch (Case.Switch__c.Name) gives a syntax error:
Error: The class 'java.lang.String' does not have the property 'Name'. |
Is there an easy way to reference this related records Name, without going adding a java query or referencing a function call in an Apex class?
Message Edited by JPSeabury on 07-28-2008 08:12 PM
Message Edited by JPSeabury on 07-28-2008 08:14 PM
My suggestion is to extend your standard controller and added method that retrieves the values you are looking for to present on the page.
Perfect, Jill -- that worked awesome. I didn't know about the "_r" relationship designator of a custom object. Need to bone up on that now. Thanks!
Good tip on the outputField option, as well -- although in this case, I'd prefer to not provide a link to the related record. Still, it's nice to know about it for other VF pages.