function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Show a custom message when user does not have permissions to view a section on Account page

I have a packaged component which is being used on an account page. 
Which does not render when a given profile does not have license to that package. 

The message displayed is: "Content cannot be displayed: You do not have sufficient privileges to access the page: /apex/abc__AccountFiles". 

How do I show a custom message there or maybe hide the section from code written in my packaged component?
Amit  TrivediAmit Trivedi
Hello Rajdeep,

Use below query to find user who dont have license and render and display message based on condition

Map<String,User> UserMap = new Map<String,User>([SELECT Name FROM User  WHERE Id  in  (SELECT UserId FROM UserPackageLicense
WHERE (PackageLicense.NamespacePrefix like '%your condition%'))  ]);
return UserMap.keySet();

Amit Trivedi
@Amit Trivedi

This is the screen shot. This is one of the Account instance pages. And, as you can see that Box Files (the user has no permission) is one of the sections. Similary Dropbox is another (user has permission). 
No permission message
I understand your approach, but where are you proposing me to add the logic from your approach?