Friday, February 11, 2022

Conditional Rendering Standard New Page and LWC

 Hello everyone,


In this post, we will see how to conditionally render an LWC component & a Standard New Page from a ListView.

In this example, we will render an LWC & Standard Page based on Logged In User Profile.

Now let's jump into the steps.

  • Click on the Gear icon and navigate to Salesforce Setup.
  • Select the Object you want to customize the standard button.
  • Now click on the Buttons, Links & Actions.
  • Select New Button & Link.
  • Select the Display type as List Button (i.e Button which is for ListView) along with content Source as URL.
  • Now use the formula given below

{!
IF( $Profile.Name !='System Administrator',
URLFOR("/lightning/cmp/c__SampleLWC", null, null),
URLFOR($Action.Account.New))
}

  • In the above Formula, we are checking for the User Profile When he is not System Administrator. Then we are going to load an LWC component(SampleLwc).
  • If the User is not the administrator then we are going to display the normal standard Salesforce Page.


  • And that's it we are all set to go.

Thanks.


Conditional Rendering Standard New Page and LWC

 Hello everyone, In this post, we will see how to conditionally render an LWC component & a Standard New Page from a ListView. In this e...