Show a Related List based on User Profile

Business Use Case: The business want to show and hide the Opportunity related list on Account record page based on User Profile in Lightning Experience.

Lightning App Builder gives you the option to show related list based on user profile without writing a single line of code. That’s amazing Right!!!

  • Navigate to an Account Record Page
  • Click on Setup icon on the Right top of your desktop screen
  • Select Edit Page
Showing a Related List based on User Profile in Lightning Experience
  • You will see the Lightning App Builder with Account page open in edit mode
  • In left hand side, You can see all the standard and custom components available to use on your record page. Search for Related List – Single component and drag it on canvas
Showing a Related List based on User Profile in Lightning Experience
  • Once you have dragged your Related List – Single component on canvas, You can set the attribute to define the underlying object
Showing a Related List based on User Profile in Lightning Experience
  • select the object which you want as related list in Related List – Single Component.
  • Now, you can see opportunity associated with current account record come up in the Related List – Single Component,
  • In order to display it based on User’s Profile, We need to set the Component visibility.
  • You will find the set component visibility in properties pane in bottom corner in right hand side as shown in above image
  • Click on add filter
Business Use Case: The business want to show and hide the Opportunity related list on Account record page based on User Profile in Lightning Experience.

Solution: Lightning App Builder gives you the option to do it without writing a single line of code. That's amazing Right!!!
  • It will open a popup with option to apply filter. Select Advanced under filter type option
  • Click on select button available under field
  • It will show you four option(Permission, Record, Client, User). Select User
  • Another box will appear to select field associated with User. Select Profile and then Profile Name
  • Click on Done
  • Select the operator as equal and put your desired profile name in value field
  • Select done
  • Save your change and activate the page if not yet activated

Demo

Are you looking for LWC scenarios to practice, checkout this: – https://salesforcediaries.com/category/lwc-practice-scenarios/

Also, Do not forget to checkout the other informative blog article related to flow and LWC on Salesforce Diaries here:- https://salesforcediaries.com/category/lightning-web-component/

If you need any help, Book 1:1 meeting with here:- https://topmate.io/sanket_kumar

2 comments

  1. How to restrict Opportunity related list Object “Files” to opportunity owner ..Other users cant see the record of owner record using Component visibility?

Leave a Reply