You need to sign in to do that
Don't have an account?
Lena Christy
Display related records in a vf page of the user in the partner community
Hi everyone! I don't know if I'm asking too much, but I really need your help about this please!
I want to create a vf page that I put in the Community, where I want each user who's accesing to it, to see its own detail contact and related opportunities to its Account.
P.S. I enabled the "Partner User" for the contact and give him "Partner Community User" as a Profile.
Here is my code, I really hope you could help me with this.
I want to create a vf page that I put in the Community, where I want each user who's accesing to it, to see its own detail contact and related opportunities to its Account.
P.S. I enabled the "Partner User" for the contact and give him "Partner Community User" as a Profile.
Here is my code, I really hope you could help me with this.
<apex:page standardController="Contact" extensions="DetailPageCon"> <apex:form > <apex:pageblock id="CustomList" title="Related Opportunities" > <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}"> <apex:column value="{!o.Name}"/> <apex:column value="{!o.Account.Name}"/> <apex:column value="{!o.Type}"/> <apex:column value="{!o.Amount}"></apex:column> <apex:column value="{!o.CloseDate}"/> </apex:pageBlockTable> <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> </apex:pageblock> </apex:form> </apex:page>The controller:
public class DetailPageCon { private List<Opportunity> oppz; private Contact cntact; public DetailPageCon(ApexPages.StandardController controller) { this.cntact= (Contact)controller.getRecord(); } public List<Opportunity> getOppz() { Contact con = [Select id, Account.id FROM Contact where id = :cntact.id]; if (con.Account == null) return null; oppz = [Select id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where Account.id = :con.Account.id]; return oppz; } }
Next, you'll remove the standardController / extension bit in your Visualforce page and replace it with the custom controller:
Create the VF tab with the proper permissions for your community profile, and add it to the list of tabs in your community.
All Answers
Then just call your page with the id parameter like so:
/apex/pages/<your page name goes here>?id=<id of the contact record goes here>
Thank you James Loghryy for your remark about the controller!
About the community, what I'm trying to do is when the partner user access to the community(SALESFORCE TABS + VISUALFORCE), he can see a Tab (where I want to make this VF page) so he can see his information about the contact and the opportunities of its Account.
I think that using Global Variables like $User, is the answer, but I really don't know to work with and use it in the controller ... If you could help me I would be grateful .
Next, you'll remove the standardController / extension bit in your Visualforce page and replace it with the custom controller:
Create the VF tab with the proper permissions for your community profile, and add it to the list of tabs in your community.