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!!!
Steps to follow:-
- Navigate to an Account Record Page
- Click on Setup icon on the Right top of your desktop screen
- Select Edit Page
- 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
- Once you have dragged your Related List – Single component on canvas, You can set the attribute to define the underlying object
- 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
- 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