0

i want to create a visualforce page for community cloud that will show the logged in user's details. the following code just shows empty fields:

<apex:page standardController="User" showHeader="true">
  <apex:form >
          <apex:pageBlock >
              <apex:pageBlockButtons >
                  <apex:commandButton action="{!save}" value="Save"/>
                  <apex:commandButton action="{!edit}" value="Edit"/>
              </apex:pageBlockButtons>
              <apex:pageBlockSection title="User Detail">
                  <apex:repeat value="{!$ObjectType.User.FieldSets.InspectorUserMain}" var="f">
                      <apex:outputField value="{!User[f]}" >
                          <apex:facet name="header">User Detail</apex:facet>
                          <apex:inlineEditSupport event="ondblclick"/>
                      </apex:outputField>
                  </apex:repeat>
              </apex:pageBlockSection>
              <apex:pageBlockSection title="Additional Information">
                  <apex:repeat value="{!$ObjectType.User.FieldSets.InspectorAdditionalData}" var="f">
                      <apex:outputField value="{!User[f]}" >
                          <apex:facet name="header">Additional Information</apex:facet>
                          <apex:inlineEditSupport event="ondblclick"/>
                      </apex:outputField>
                  </apex:repeat>
              </apex:pageBlockSection>
          </apex:pageBlock>
      </apex:form>
</apex:page>

Any idea how to tell the page to show the logged in user's details???

Thanks.

1

Here's an idea. You can use the $User Global Variable to get the running user Id. With it, you can run a script that redirects to include this Id when it is left off.

<apex:page standardController="User">
    <apex:outputText value="{!User.Name}" />
    <script>
        (function (w) {
            "use strict";
            if (!w.location.search || w.location.search.indexOf('id=') < 0) {
                w.location.search = '?id={!$User.Id}';
            }
        }(window));
    </script>
</apex:page>

In theory, you should be able to do it without Javascript using the action attribute on your <apex:page> tag, possibly in conjunction with a controller extension, but I wasn't able to whip up a POC for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.