Find your content:

Search form

You are here

Customizing visualforce permission error message

 
Share

We are using an appexchange app that consists of a visualforce inline page. This visualforce page connects to a third-party API and displays some information on a record detail page. The licensing for this app is not done through the appexchange, but through the third-party API. So this app is deployed to all users although most of them will not get any functionality from it.

We have licenses for just a fraction of our users. All licensed users share the same profile. Currently all users that share that profile will see the visualforce page on the page layout, but the licensed users will see the information as intended, and unlicensed users will see a message that they need to request a license. This is obviously not going to work because everyone wants a license to this app.

Please assume that creating new profiles and page layouts for the licensed users is not an option. It will create too many headaches going forward from a maintenance perspective.

We have somewhat resolved this by removing access to all fields, visualforce, and apex belonging to this app from all profiles. Then we can add those permissions using permission sets for users that have a license to the app. Now when an unlicensed user views the page, in place of the VF page, they will see a message that says 'Content cannot be displayed: You do not have sufficient privileges to access the page: '.

This solution is almost works for us, but we would like to be able to customize that message. However, this is a standard salesforce message indicating that the user does not have permissions to view the page, so I do not believe it can be customized.

Any solution that would allow us to customize that message or better yet - completely hide the VF page or page layout section from all users would be suitable.


Attribution to: Eric Nelson

Possible Suggestion/Solution #1

Create a sidebar component with javascript and check for string 'Content cannot be displayed: You do not have sufficient privileges to access the page:' replace it with your message.

Similar kind of ready code available here - http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/

I used this code to do lots of changes on default page layouts.


Attribution to: Prafulla Patil

Possible Suggestion/Solution #2

I'm not sure how to change that message for your particular page, so maybe someone else will come along with a solution for that.

I know that you mentioned not being able to create new page layouts, but do you have access to the existing page layout where you could remove the Visualforce section on the page layout? If so, could you remove it and then add your own that conditionally includes it:

<apex:page standardController="YourObject" extensions="YourExtensionThatChecksForLicense">
 <apex:include pageName="theThirdPartyVfPage" rendered="{!hasLicense}"/>
</apex:page>

Attribution to: Peter Knolle
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/857

My Block Status

My Block Content