You need to sign in to do that
Don't have an account?
Prasan De Alwis
How to Show/Hide button based on Profile in Salesforce LWC?
Hi,
I have develop LWC component which is normally used by normal users. In that lightning web component button is there as below.
I have develop LWC component which is normally used by normal users. In that lightning web component button is there as below.
<lightning-button slot="actions" label="Deactivate" onclick={DeactivateProcess}> </lightning-button>The above button should be only be show to System Admin Profile and Business Admin Profile. How to show the button only to those two Profiles without using record types or different page layouts?
Try The Below Code
Please Mark It As Best Answer If It Helps
Thank You!
All Answers
>> https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.get_current_user
>> https://rajvakati.com/2019/02/11/get-current-user-details-in-lightning-web-components/
The above link shows how to access current user details.
You can use the above in conjunction with this link[ https://www.infallibletechie.com/2019/06/simple-hide-and-show-in-lightning-web.html ] which has an example of show or hide text on button click you need to modify it to fit your scenario.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Try The Below Code
Please Mark It As Best Answer If It Helps
Thank You!
Hi Prasan De Alwis,
You can do this through your component:
<template if:true={btnVisibility }>
<lightning-button label="ProfileButton" ></lightning-button> </template>
@track data;
btnVisibility = false;
this.data = data;
if(this.data == 'System Administrator' || this.data == 'Business Administrator'){
this.btnVisibility = true;
}
else{
this.btnVisibility = false;
}
Please Mark it as Best Answer,if it helps!
Thanks