1

Background: We use cases internally to manage sfdc requests. I'm testing out service cloud now that its included in nonprofit lightning edition. I have built a simple visualforce page using user standard controller that displays some relevant fields from user, related permission sets, and uses a custom visualforce component to display a count of records owned by user for contacts, opps, and a few other objects. Works perfectly well as a sidebar component.

Sample Screenshot on User (ignore the editable user fields - not a requirement - and the second tab, which is separate)

screenshot of sidebar component

Question: I want to display this page in the console sidebar for all objects, using the object owner as the user in all but a few cases. So if I'm looking at any object other than a user or a case, the page would display the relevant data with the user == record.owner. If I'm looking at a user, the user itself. And if its a case, evaluate user as defined by a custom lookup to user.

I'm wondering if its possible to build this without building a custom controller. Could I use the user standard controller with an extension that will 'handle' parsing the correct field to use based on the scenario,or some other option?

Or, do I need to use a custom controller that is built to use generic sObjects, determine sObject type, and return a user object (with the permissionSetAssignment child object) to the page, which can display the data?

Since there are only two exceptions (case and user), which I could handle by building pages specifically for those objects, the primary need is to understand how I could best build a page that would work for record owner on any object type.

I know I would have to tweak the page layouts for each object to add the sidebar component, but this way it would just be one visualforce page to maintain.

Currently my page uses the user standard controller with an extension for the custom component. I'm including the code for the visualforce page in case its helpful. I can deal w/ the extension once I figure out the possible approaches.

<apex:page standardController="User" extensions="UserRecordDetailExtension">

<apex:pageBlock >
<apex:facet name="header">
<span class="title"><a href="/{!user.Id}?noredirect=1&isUserEntityOverride=1" target="blank">User Details</a></span>
</apex:facet>

<apex:pageblockSection columns="1">
<apex:outputPanel id="uDetail">
<ul style="padding-left:0px; margin-top:0px;">
<li>User Name: {!user.Name} </li>
<li>Profile: {!user.Profile.Name}</li>
<li>Role: {!user.UserRole.Name}</li>
<li>License Type: {!user.Profile.UserLicense.Name}</li>
<li>Is Active: {!user.IsActive}</li>
<li>Deactivation Date: <apex:outputText value="{0, date, MMMM d','  yyyy}"><apex:param value="{!user.Deactivation_Date__c}" /> </apex:outputText></li>
<li>Sysadmin Notes: {!user.Sysadmin_Notes__c}</li>
</ul>

</apex:outputPanel>
</apex:pageblockSection>

<apex:pageBlockSection columns="1" rendered="{!IF($Profile.Name = 'System Administrator', TRUE, FALSE)}">
<apex:form >
<apex:pageblockSectionItem >
<apex:inputField value="{!User.ProfileId}"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:inputField value="{!User.UserRoleId}"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:inputField value="{!user.Sysadmin_Notes__c}" label="Update" style="width:90%; height:5em;"/> <br />
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:commandButton action="{!saveChanges}" reRender="uDetail" value="Update Sysadmin Notes"/>
</apex:pageblockSectionItem>
</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>

<apex:pageBlock >
<apex:facet name="header">
<span class="title"><a href="/apex/User_Record_Details?id={!user.Id}" target="_blank">Records owned by user</a></span>
</apex:facet>

<apex:pageblockSection columns="1">
<c:User_Storage_URL userId="{!user.Id}" baseURL="https://na2.salesforce.com" /><br />
<a href="/setup/user/userstorageusage.jsp?id={!user.Id}" target="_blank" >full list</a>
</apex:pageblockSection>


</apex:pageBlock>

<apex:pageBlock >
<apex:facet name="header">
<apex:outputLink value="/udd/PermissionSet/assignPermissionSet.apexp?userId={!user.Id}" id="theLink" styleClass="title">Permission Sets</apex:outputLink>
</apex:facet>
<apex:pageblockSection columns="1"> 

<apex:pageblocktable var="ps" value="{!User.PermissionSetAssignments}">
<apex:column >
<a href="/{!ps.PermissionSet.Id}" target="_blank">{!ps.PermissionSet.Label}</a>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:page>

Your Answer

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

Browse other questions tagged or ask your own question.