• RailCIO
  • NEWBIE
  • 0 Points
  • Member since 2012
  • CIO
  • SMBC Rail Services

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

So the problem here is how to move from a Master File to a junction file over to the other Master file using the apex relatedto command within a Visualforce Email template.

We lease fleets of cars and we are developing a process to provide detail from both the standard Contract object,  a custom built Car object and a junction object named Contract Cars. 

Using a Visualforce email communicaton template related to the Contract object, i am able to pull in all values from related tables.  I am having difficulty in the naming of the junction table as a bridge over to custom Car object.   The link from the junction object Contract Car to the custom Car object is name Car__C.  In this example it is defiend as Car__R.   Below is a small sample of the code. 


 <messaging:emailTemplate subject="Approval" recipientType="User" relatedToType="Contract">

  <messaging:htmlEmailBody >
  <html>
     <body>
       <font face="arial" size="2">
       <p>Contract Rates </p>
        <table border="0" >
          <tr >
        <th>Contract Cars</th>
        </tr>
       <apex:repeat var="cc" value="{!relatedTo.Contract_Cars__r}">
       <tr>
          <td>{!cc.name}</td>
          <td>{!cc.car__r.car_id}</td>
        </tr>
        </apex:repeat>                
      </table>
   </font>
   </body>
   </html>
  </messaging:htmlEmailBody>

I have a custom object Quote__c with a lookup field called Enquiry__c to another custom object Enquiry__c. Eveyrthing I have read implies that in a standard controller for the child Quote__c object, I should be able to access fields in the parent object using dot notation, e.g., I should be able use the following line in an VFpage:

 

<p>Name is: {!Quote__c.Enquiry__c.Name}</p>

 

but when I try to save, I get the error Unknown property 'String.Name'

 

If I put it in an apex field

<p>Name is:<apex:outputField value="{!Quote__c.Enquiry__c.Name}"/></p>

 

I get the error "Could not resolve the entity from <apex:outputField> value binding '{!Quote__c.Enquiry__c.Name}'. outputField can only be used with SObject fields."

 

The documentation is REALLY confusing. In the Visual Force Developers Guide, in the section "Displaying Field Values with VisualForce", it says "You cannot access parent objects using this expression language. In other words, {!account.parent.name} will return an error." Yet, I tried that exact expression (on the implied standard objects) and it worked fine!

 

Then, in a later section "Accessing Data with a Standard Controller", it contradicts the previous statement by saying "You can traverse up to five levels of child-to-parent relationships. For example, if using the Contact standard controller, you can use {!contact.Account.Owner.FirstName} (a three-level child-to-parent relationship)" I tried that expression and IT worked fine.

 

Yet, my custom object expression cannot even access data in the first parent!  Are custom objects treated differently than standard objects by standard controllers?  Any hint as to what is going on would be deeply appreciated!

Hello, Forum:

 

I've read various posts around the forums concerning the defaulting in of values from a parent object into a newly created child object.  But I still don't see a solution out there.

 

I've created a VF page.  Using a topmost pageBlock, I've created a sort of boilerplate region where certain key information from the parent object is displayed.  This is a common technique, and it serves to orient the user in the child object with respect to the parent object.

 

But I'm having trouble implementing this technique.  It seems that newly created child objects do not have access to parent object values.  This is absolutely essential.  I need to fill in certain child fields based on values in the parent.  For example, in the boilerplate region, I need to display the project name of the parent object, not just its name.  The bid due date and time on the parent object needs to default in as the bid due date and time for the child object, etc.

 

Is there a way to accomplish this with JavaScript?  If we can't accomplish this, it would be a dealbreaker for us with SF.

 

Thank you.

  • February 01, 2010
  • Like
  • 0