1

Is it possible to have a visual force page load a different record based on the User who is going to that Visual force page? So I am working with Communities on this one, and I want the users to login and be sent directly to their own contact record. Their Contact record is listed on the user record. So I was thinking that I could maybe put in a redirect and then look at that field and do a page reload and just merge in that id to send them to the right record. But I have just been spinning for a while I can't seem to figure out which way to go.

1 Answer 1

1

If you just want to show the detail page, then you could use the <apex:detail> component:

<apex:page>
    <apex:detail subject="{!$User.ContactId}" rendered="{!NOT(ISNULL($User.ContactId))}" />
</apex:page>
7
  • Adrian, One final thing. I think I want to change this up to have the page that is loaded be that Contact's Account. I Changed the merge field to be this {!$User.Contact.AccountId} which I verified that relationship name and field name in workbench and it is saying Error: Could not access the following field: Contact.AccountId. Contact your administrator
    – cmmoutes13
    Commented Jun 13, 2017 at 20:04
  • Might be a permissions issue. Sounds like a separate question, honestly. Though I'm sure there are some Q&A posts around here that address accessing AccountId as a community user.
    – Adrian Larson
    Commented Jun 13, 2017 at 20:05
  • I don't see how it would be a permission issue. I am getting the error while making the visual force page, not when the user logs in.
    – cmmoutes13
    Commented Jun 13, 2017 at 20:11
  • @cmmoutes13 You might need to add a controller/extension to get the AccountId value. Probably can't pull cross-object data from the $User global variable.
    – Adrian Larson
    Commented Jun 13, 2017 at 20:13
  • Yeah, I thought maybe I could also work around this by bringing the Account Id down to a field on the User using a formula field. And that lets me save it, but then when the community user logs in they don't get redirected to it properly so idk
    – cmmoutes13
    Commented Jun 13, 2017 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .