You need to sign in to do that
Don't have an account?
Manpreet Singh 207
Related List in Visualforce Page
Hello All - Working on visualforce page and controller. We have parent object (Authorized Pickup) and child object (Authorized Kid). There is lookup relationship between these 2 objects.
There is custom field in Authorized Pickup object (Unique Key) when when searched should show list of chidren from the related list for the record wherein Unique Key has matched.
Here is my Visualforce Page
<apex:page showheader="false" Controller="SearchInVFController">
<apex:relatedList list="Authorized_Kid__c" title="List of Kids"/>
<apex:form >
<table>
<tr>
<td width="1500px" height="100px" align="center">
<apex:image url="https://pjcc--fullsand--c.cs43.content.force.com/sfc/servlet.shepherd/version/download/06863000000EBIv"/>
</td>
</tr>
</table>
<br><center><br><b><h1>This is PJCC Authorized Pickup Application</h1></b></br></center></br>
<center><b><h1>Enter Unique Key: </h1></b><apex:inputText value="{!searchKey}" label="Unique Key"/></center>
<center><apex:commandButton value="Search" action="{!search}"/></center>
<apex:pageBlock title="Search Result">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.Child_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<center><apex:commandButton value="Submit"/></center>
</apex:form>
</apex:page>
Here is my class
public class SearchInVFController {
public Authorized_Pickup__c apc;
public list <Authorized_Kid__c> acc {get;set;}
public String searchKey {get;set;}
public SearchInVFController( ) {
}
public void search(){
string searchquery='select Authorized_Authorized_Pickup__r.Child_Name__c from Authorized_Pickup__c where name like \'%'+searchKey+'%\' Limit 10';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
Error: I am getting this error. What am i missing
Didn't understand relationship 'Authorized_Authorized_Pickup__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Error is in expression '{!search}' in component <apex:commandButton> in page atp: Class.SearchInVFController.search: line 10, column 1
An unexpected error has occurred. Your development organization has been notified.
There is custom field in Authorized Pickup object (Unique Key) when when searched should show list of chidren from the related list for the record wherein Unique Key has matched.
Here is my Visualforce Page
<apex:page showheader="false" Controller="SearchInVFController">
<apex:relatedList list="Authorized_Kid__c" title="List of Kids"/>
<apex:form >
<table>
<tr>
<td width="1500px" height="100px" align="center">
<apex:image url="https://pjcc--fullsand--c.cs43.content.force.com/sfc/servlet.shepherd/version/download/06863000000EBIv"/>
</td>
</tr>
</table>
<br><center><br><b><h1>This is PJCC Authorized Pickup Application</h1></b></br></center></br>
<center><b><h1>Enter Unique Key: </h1></b><apex:inputText value="{!searchKey}" label="Unique Key"/></center>
<center><apex:commandButton value="Search" action="{!search}"/></center>
<apex:pageBlock title="Search Result">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.Child_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<center><apex:commandButton value="Submit"/></center>
</apex:form>
</apex:page>
Here is my class
public class SearchInVFController {
public Authorized_Pickup__c apc;
public list <Authorized_Kid__c> acc {get;set;}
public String searchKey {get;set;}
public SearchInVFController( ) {
}
public void search(){
string searchquery='select Authorized_Authorized_Pickup__r.Child_Name__c from Authorized_Pickup__c where name like \'%'+searchKey+'%\' Limit 10';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
Error: I am getting this error. What am i missing
Didn't understand relationship 'Authorized_Authorized_Pickup__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Error is in expression '{!search}' in component <apex:commandButton> in page atp: Class.SearchInVFController.search: line 10, column 1
An unexpected error has occurred. Your development organization has been notified.
Hi Manpreet,
For custom object relationship field is defined with ('__r'). Change 'Authorized_Kid__c' with 'Authorized_kids__r'
Check with below link
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_custom_mapping.htm
Thanks,
Sucharita
Didn't understand relationship 'Authorized_kids__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Error is in expression '{!search}' in component <apex:commandButton> in page atp: Class.SearchInVFController.search: line 10, column 1
An unexpected error has occurred. Your development organization has been notified.
Updated Page
<apex:page showheader="false" Controller="SearchInVFController">
<apex:relatedList list="Authorized_Kid__r" title="List of Kids"/>
<apex:form >
<table>
<tr>
<td width="1500px" height="100px" align="center">
<apex:image url="https://pjcc--fullsand--c.cs43.content.force.com/sfc/servlet.shepherd/version/download/06863000000EBIv"/>
</td>
</tr>
</table>
<br><center><br><b><h1>This is PJCC Authorized Pickup Application</h1></b></br></center></br>
<center><b><h1>Enter Unique Key: </h1></b><apex:inputText value="{!searchKey}" label="Unique Key"/></center>
<center><apex:commandButton value="Search" action="{!search}"/></center>
<apex:pageBlock title="Search Result">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.Child_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<center><apex:commandButton value="Submit"/></center>
</apex:form>
</apex:page>
Updated Class
public class SearchInVFController {
public Authorized_Pickup__c apc;
public list <Authorized_Kid__c> acc {get;set;}
public String searchKey {get;set;}
public SearchInVFController( ) {
}
public void search(){
string searchquery='select Authorized_kids__r.Child_Name__c from Authorized_Pickup__c where name like \'%'+searchKey+'%\' Limit 10';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
Another Question - Do I need to use (Authorized_Authorized_Pickup__r) Relationhsip name or (Authorized_kids__r) object name?
Whenere we go from Parent to child --> User Sub query.
The above SOQL will not work as 'Authorized_Pickup__c ' is Parent and ' Authorized_Kid__c' is Child.
SOQL should be as :- [select Name,(select name from Authorized_Kids__r) from Authorized_Pickup__c ]
then using For loop iterate is further and do assignment.
Check this link and you'll get about using sub-queries
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_custom_mapping.htm
Thanks,
Sucharita