You need to sign in to do that
Don't have an account?
Ankit Arora 30
Visualforce page using custom object display on portal
Hi Everyone,
I have a "Contact" object and a custom child object "FinancialAid" Object. I want to create a VF page that displays FinancialAid object records but I want to display that page on Contact Object or any object I want to. Also, How can I pass an ID to it. Currently, I am using hardcoded ID of the contact record. I want to fetch the ID automatically from the page.
VF Page:
<apex:page controller="FinAidData">
<apex:pageBlock title="Financial Aid Information">
<apex:pageBlockTable value="{!finaidresults}" var="finaid">
<apex:column value="{!finaid.Name}"/>
<apex:column value="{!finaid.Amount__c}"/>
<apex:column value="{!finaid.Accepted__c}"/>
<apex:column value="{!finaid.Accept_Date__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
APEX Class:
public class FinAidData {
List<Financial_Aid__c> finaidresults = [Select Name, Amount__c, Accepted__c, Accept_Date__c from Financial_Aid__c where Contact__c = 'XXXXX000035Mp7XXXX' ];
public List<Financial_Aid__c> getfinaidresults(){
return finaidresults;
}
}
I have a "Contact" object and a custom child object "FinancialAid" Object. I want to create a VF page that displays FinancialAid object records but I want to display that page on Contact Object or any object I want to. Also, How can I pass an ID to it. Currently, I am using hardcoded ID of the contact record. I want to fetch the ID automatically from the page.
VF Page:
<apex:page controller="FinAidData">
<apex:pageBlock title="Financial Aid Information">
<apex:pageBlockTable value="{!finaidresults}" var="finaid">
<apex:column value="{!finaid.Name}"/>
<apex:column value="{!finaid.Amount__c}"/>
<apex:column value="{!finaid.Accepted__c}"/>
<apex:column value="{!finaid.Accept_Date__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
APEX Class:
public class FinAidData {
List<Financial_Aid__c> finaidresults = [Select Name, Amount__c, Accepted__c, Accept_Date__c from Financial_Aid__c where Contact__c = 'XXXXX000035Mp7XXXX' ];
public List<Financial_Aid__c> getfinaidresults(){
return finaidresults;
}
}
Hi Ankit,
Greetings!
You would need to query the Contact records based on your requirement and store in the list.
List<Contact> contacts=[Select Id from Contact where the condition];
Then,you need to use the list of Ids to search for the Financial Aid records.
The below thread might help you for the same scenario:
https://salesforce.stackexchange.com/questions/3526/elegant-way-to-convert-setid-into-string-for-dynamic-soql-in-comparison
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
public class FinAidData {
List<Financial_Aid__c> finaidresults = [Select Name, Amount__c, Accepted__c, Accept_Date__c from Financial_Aid__c where Contact__c =: ApexPages.currentPage().getParameters().get('id'); ];
public List<Financial_Aid__c> getfinaidresults(){
return finaidresults;
}
}
then I amend the URL with the contact id (?id=XXXXX000035Mp7XXXX) and its working. Now I know the code is working when we pass the id in the URL, it displays the financial aid records specific to that student. Now I want to display this vf page on the contact object but I can't find in the list of vf pages on the page layout and also I tried to create a link or button but I can't find the name of this vf page.
Regards,
Ankit