2

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.

3

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).

  • So, turns out there appears to be a "bug" with this approach, though it's not a deal breaker for me; meaning I still plan to use this approach in part because as a result of the bug being present on 100% of the tabs displayed, it's less noticeable. So, bug is that the "real" accounts tab, which is hidden, is the tab that's shown as being active, even though it's not; meaning if you have the real & custom tabs displayed, click the custom tab, the real tab is highlighted as being selected even though it is not. Played around with both the code, tab-names, etc. and nothing appears to fix this. – blunders May 24 '14 at 17:40
  • 1
    I thought you were going to override the standard tab with this? Go to Setup > Accounts > Buttons, Links and Actions and hit "Edit" next to "Tab". Change the code to <apex:page readonly="true" tabStyle="Account"> (no std controller specified) and it should become selectable. If you still need server-side checks - just use regular controller and not an extension class. – eyescream May 24 '14 at 17:54
  • +1 Thanks, attempted your suggestion on the tabs, but unable to get it to work. Posted a question covering what I tried and showing what I'm seeing here: How to override default contacts tab with custom visualforce contacts tab? – blunders May 24 '14 at 20:03

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.