[SalesForce] How to recreate Contact, Account, & Opportunity homepages with Visualforce pages

An answer, from this question, "How to remove Reports & Tools from the Contact, Account, & Opportunity homepages?," suggest the following:

If you are open for writing Code then here is one alternative.

  1. Create a VF page and list all contact give link to standard edit/ new screen (same like existing list page)
  2. Add tab for this VF page
  3. Remove existing Contact tab from UI

Repeat above steps for all other objects. This needs development
efforts but you will be able to control everything non the list view
page.

Putting aside steps 2 & 3, how would I implement step 1, that being, create a Visualforce page that copies all features of the default list contact, account, & opportunity pages, but allows me to customize the page based on the user's permissions; currently, this appears not to be the case, and as a result, appears to be a bug.

Also, just to be clear, I am not looking for how to do everything, just as a high-level the steps that would be required to implement this, or suggestions on aspects that I may not have accounted for.

Best Answer

I'm not sure I understand your question. Ideally you'd like to list all Contacts(etc) with correct links ("Edit" only if I'm really able to Edit that particular record, "Del" similarly etc)? And then you'd like this page to be an overridden tab for Contacts?

Or is it only about hiding the "Reports" and "Tools" if some conditions are met?

A quick & dirty tab recreated as Visualforce would look like that:

<apex:page standardController="Account" readonly="true">
    <apex:sectionHeader title="{!$objectType.Account.LabelPlural}" subtitle="Home"/>
    <apex:ListViews type="Account" />
    <apex:panelGrid columns="2" width="100%">
        <apex:pageBlock title="Reports" rendered="{!$Profile.Name = 'System Administrator'}">
            links here, based on security checks I guess
        </apex:pageBlock>
        <apex:pageBlock title="Tools">
            more links... use a ctrl. extension to test permissions, group membership etc if needed?
        </apex:pageBlock>
    </apex:panelGrid>
</apex:page>

enter image description here

It's not a 100% match because real tabs display "Recent Items" when you navigate to them (listviews are shown only after you click-through).

Which personally I've never liked but if you really want it - you can use REST API to fetch the data following the awesome answer by Daniel Ballinger: How can I get 'Recent Items' object Ids in Apex (soql) is it possible; it used to be available only in REST API (which means a server-side call would be best as this item has <apex:pageBlock> written all over it) but the Daniel Hoechst's answer also rocks hard ;)

So yeah, use this as starting point and hack away? Get the "Recent Items" right (or leave it as is, straight to the listview like I did).

If you're really after getting permissions to every single record displayed right - you probably should read up about StandardSetController (to deal with listviews & pagination) and UserRecordAccess table (to have a flattened view of 'this' user's permissions to edit/delete 'these' records).

Related Topic