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
rwalrath144rwalrath144 

Related List on VisualForce page

I created a customer object called New Call Log. The call log is related to Solutions object where solutions is the parent. I am trying to create a VF page with Call log is the controller. A rep would enter in the information regarding the call and on the same page the Solution is shown below the call. I have been trying to work with sample code from the Recruiting application but it isn't working. This is what I have so far.

 

<apex:page standardController="New_Call_Log__c" id="thePage" showHeader="false"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!quickSave}" reRender="out, in" status="status"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockSection columns="1"> <apex:inputField value="{!New_Call_Log__c.Who_is_Calling__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Reason_for_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Additional_Details__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Date_of_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Name_of_Caller__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Callers_Email__c}"></apex:inputField> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Solutions"> <apex:pageBlockTable value="{!New_Call_Log__c.solution__r}" var="JA" title="Solutions"> <apex:column value="{!JA.Solution__r.SolutionNote"></apex:column> <apex:column Value="{!JA.Soluiton__r.Incident_Reason__c"></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

 

Any help would be very appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
AmphroAmphro

Ohh so there is a New_Call_log__c lookup field on the Solutions object? In that case your first try was close. What you should do, is goto the Solution object in setup. Goto the lookup custom field. You should see something called "Child Relationship Name" Thats what you want to use. When I created a lookup field to an object on Solution, it created a relation name of "Solutions" So in your first example it whould have been

value="{!New_Call_Log__c.Solutions__r}"

 Hopefully that will fix it. Sorry that I misunderstood the first time.You made it clear when you said "Solutions is the parent."

All Answers

AmphroAmphro

It would help to know why it isn't working. But I am going to guess it is this part of you code.

 

<apex:pageBlockTable value="{!New_Call_Log__c.solution__r}" var="JA" title="Solutions">
<apex:column value="{!JA.Solution__r.SolutionNote"></apex:column>
<apex:column Value="{!JA.Soluiton__r.Incident_Reason__c"></apex:column>
</apex:pageBlockTable>

 

 

Try this.

 

<apex:pageBlockTable value="{!New_Call_Log__c.Solution__c}" var="JA" title="Solutions">
<apex:column value="{!JA.SolutionNote"></apex:column>
<apex:column Value="{!JA.Incident_Reason__c"></apex:column>
</apex:pageBlockTable>
 

 Hope that works

 

 

 

 

rwalrath144rwalrath144

I have tried it both ways with and without the Solution__r after the JA.

 

 This is the error I get:

Error: Invalid field Solution__c for SObject New_Call_Log__c 

 

The field that links the two is Possible_Solutions__c.

 

Lookup Options:

Related ToSolutionChild Relationship NameCall_Logs
  Related List LabelCall Logs
AmphroAmphro

What is the field name on New_Call_Log__c and is it a lookup? If it is Possible_Solutions__c then use that as your value. 

value="{!New_Call_Loc__c.Possible_Solutions__c}"

 

If it is not a lookupfield on the New_Call_Log__c then you will have to do it a different way. 

rwalrath144rwalrath144

I have tried the following and still come up with an error code.

 

<apex:pageBlockTable value="{!New_Call_Log__c.Possible_Solutions__c}" var="JA" title="Solutions"> <apex:column value="{!JA.SolutionNote}"></apex:column> <apex:column Value="{!JA.Incident_Reason__c}"></apex:column> </apex:pageBlockTable>

 

Possible_Solutions__c is a look up field on New Call Log object that links the object to Solutions object.

 

With the code above I get this error

 

Error: Invalid field Possible_Solutions__c for SObject New_Call_Log__c 

 

But it is a field in the object New Call Log.

AmphroAmphro

Hmm, because I did a quick test in a de org, creating a New_Call_Log__c object and a Solution__c object. Gave New_Call_Log__c a lookup to Solution__c. And the code worked fine. 

Are you sure its not Possible_Solution__c instead of Possible_Solutions__c

rwalrath144rwalrath144

You are right. I have been staring at the code for too long. I didn't even catch that because I always try to copy and paste the name of the field. Now I am getting a new error.

 

<apex:pageBlockTable value="{!New_Call_Log__c.Possible_Solution__c}" var="JA" title="Solutions"> <apex:column value="{!JA.SolutionNote}"></apex:column> <apex:column Value="{!JA.Incident_Reason__c}"></apex:column> </apex:pageBlockTable>

 

 The error I get is:

Error: Unknown property 'String.SolutionNote' 

 

Thank you for all your help so far. I am at point where I just can't look at it anymore and need a fresh set of eyes.

 

Rachael

AmphroAmphro

lol No Problem. Trust me I know how that is. Since it is a custom object I am assuming it is a custom field. Try this

JS.SolutionNote__c

 Hope that works

rwalrath144rwalrath144
I have tried everything, S-Control, Class, Trigger and VF page to make this connection but can't seem to make it work. I am trying to call information from the "Solution" object which is not a custom object onto the Visualforce page controlled by "New Call Log" which is a customer object. I am trying to make a Child (New Call Log) - Parent (Solution) connection. I have read every document and post I can get my hands on. I follow exactly what is shown and it doesn't work. I am out of ideas.
AmphroAmphro

Ohh so there is a New_Call_log__c lookup field on the Solutions object? In that case your first try was close. What you should do, is goto the Solution object in setup. Goto the lookup custom field. You should see something called "Child Relationship Name" Thats what you want to use. When I created a lookup field to an object on Solution, it created a relation name of "Solutions" So in your first example it whould have been

value="{!New_Call_Log__c.Solutions__r}"

 Hopefully that will fix it. Sorry that I misunderstood the first time.You made it clear when you said "Solutions is the parent."

This was selected as the best answer
rwalrath144rwalrath144

Well you sort of got it. I had a look up field called Possible_Solution__c on the custom object "New Call Log". Possible_Solution__c is a Master Detail look up field linked to "Solutions" object where "Solutions" is the Parent. Making Possible_Solution__c the child. I tried to add a field onto "Solutions" where New Call Log is the Parent and Solutions is the child. I used that field "Call_Log__c" but it didn't work.

 

After I created the new field and retried my original code, it finally worked. Now I am having another issue. The columns are not working. I tried the original code for the columns and different code I found but neither work. Here is what it looks like:

 

apex:pageBlock title="Solutions"> <apex:pageBlockTable value="{!New_Call_Log__c.Possible_Solution__r}" var="JA" title="Solutions"> <apex:column> <apex:facet name="Solution Title"> <apex:outputText value="SolutionNote"></apex:outputText> </apex:facet> </apex:column> <apex:column value="{!JA.SolutionNote}"></apex:column> <apex:column Value="{!JA.Incident_Reason__c}"></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

AmphroAmphro

What do you mean "The columns are not working?" Error? No data?

The only thing I see wrong with your code is your facet. I'm not sure what you are trying to do, but the only two values a facet name can have are "header" and "footer". 

Did you create any records? In other words, is Possible_Solution__r empty?