You need to sign in to do that
Don't have an account?
Jean-Se Dorais
Pull result of Select statement in VF Page
Hi all,
Newbie here.
I've got the following VF code that generates a Word doc when an action button is pressed on a custom object (Contract_Work_Order__c).
I'm trying to retrieve a contact's full name based on its id. The field below is returning the Contact ID.
{!Contract_Work_Order__c.Contractor__c}
I essentially need to write the following select statement and return the value.
Here's the current VF page:
I'm stuck and would appreciate your pointers!
Thank you.
Newbie here.
I've got the following VF code that generates a Word doc when an action button is pressed on a custom object (Contract_Work_Order__c).
I'm trying to retrieve a contact's full name based on its id. The field below is returning the Contact ID.
{!Contract_Work_Order__c.Contractor__c}
I essentially need to write the following select statement and return the value.
Select name from contacts where Id ={!Contract_Work_Order__c.Contractor__c}
Here's the current VF page:
<apex:page standardController="Contract_Work_Order__c" contentType="application/msword#MSA_{!Contract_Work_Order__c.Id}.doc" sidebar="false" standardStylesheets="false" applyBodyTag="false"> <div style="font-family:sans-serif;"> <center> <h4>MASTER SUB-CONSULTANT AGREEMENT</h4> </center> </div> <div style="font-family:sans-serif;text-align:left;font-size:10pt;"> <p>This MASTER SUB-CONSULTANT AGREEMENT ("Agreement") is made and entered into as of <apex:outputText value=" {!TODAY()}"/> (“Effective Date”), by and between XYZ, and <apex:outputText value=" {!Contract_Work_Order__c.Contractor__c}"/> ("Sub-Consultant”), each individually sometimes referred to as a “Party” and collectively as “Parties”.</p> <p>Your account details are:</p> <table> <tr><th>Opportunity Name</th> <td><apex:outputText value="{!Contract_Work_Order__c.Opportunity__c}"/></td> </tr> <tr><th>Account Rep</th> <td><apex:outputText value="{!Contract_Work_Order__c.Account_Rep__c}"/></td> </tr> <tr><th>Customer Since</th> <td><apex:outputText value="{0,date,long}"> <apex:param value="{!Contract_Work_Order__c.CreatedDate}"/> </apex:outputText></td> </tr> </table> <p>It's a pleasure to have you on board. Please do not hesitate to contact us should you have any questions or concerns.</p> <p>Sincerely,</p> <p><apex:outputText value="{!Contract_Work_Order__c.CreatedById}"/></p> </div> </apex:page>
I'm stuck and would appreciate your pointers!
Thank you.
You can use child to parent relationship __r to show the contact name
{!Contract_Work_Order__c.Contractor__r.Name}
This will get you the desired output.
All Answers
You can use child to parent relationship __r to show the contact name
{!Contract_Work_Order__c.Contractor__r.Name}
This will get you the desired output.
Yes, the code above worked. Great to learn about the __r for related object data. Marked as best.
Thank you!