Loading
메일 전송 도메인 확인 상태 안내더 많이 읽기

Salesforce Apex: Hide a Custom List View Button from Specific Profiles

게시 일자: Jun 9, 2026
상세 설명

In Salesforce, custom list view buttons are visible to all users by default and cannot be hidden from specific profiles using declarative configuration alone. To restrict visibility of a custom list view button to certain profiles, a development-based workaround is required. This article covers two approaches: using a Visualforce page to replicate the list view, or adding Apex logic to the button's onclick handler.

솔루션

The following two workarounds allow you to control which profiles can use a custom list view button. Choose the approach that best fits your org's requirements and development resources.

Option 1: Develop a Visualforce Page with Profile-Based Button Visibility

Create a Visualforce page that replicates the list view layout and replaces the list view page for affected users. Within the page, use Apex to evaluate the running user's profile and conditionally display or hide the button using the apex:commandButton rendered attribute.
Note: This approach requires re-querying and re-rendering all list view data and is more complex to implement.

Option 2: Add Profile-Based Apex Logic to the Button's OnClick Handler

Add an Apex-based JavaScript snippet to the button's OnClick property. The snippet checks the running user's Profile ID or Profile Name and either executes the button's intended action or displays a permission-denied message. The button remains visible to all profiles, but only authorized profiles can successfully use its functionality.


Note: In this approach the button is always shown to all profiles but can only be used by authorized profiles.
If you would like to see native profile-based button visibility implemented as a platform feature, you may vote for the related Idea on the Salesforce Trailblazer Community.

Knowledge 기사 번호

000384946

 
로드 중
Salesforce Help | Article