You need to sign in to do that
Don't have an account?

Custom Button visibility using permission set in VF page
Hi All,
I have custom button (Edit and clone ) in my VF page and my requirement is for one particular permission set i need to hide those button which i created using commandbutton expression. Please help me on these.
Thanks,
Anish
I have custom button (Edit and clone ) in my VF page and my requirement is for one particular permission set i need to hide those button which i created using commandbutton expression. Please help me on these.
Thanks,
Anish
I used following code and it works for me.
Public Set<String> permissionSetNameList;
Public Set<String> userPermissionList;
Public Set<String> userProfileSet;
Public Boolean relatedListFlag {get;set;}
public void Custombutton()
{
permissionSetNameList =New set<String>();
userPermissionList=New set<String>();
userProfileSet=New set<String>();
for(PermissionSetAssignment permission : [SELECT Id, PermissionSet.Name FROM PermissionSetAssignment WHERE AssigneeId =:UserInfo.getUserId() ])
{
permissionSetNameList.add(permission.PermissionSet.Name);
}
userPermissionList.addAll(permissionSetNameList);
for(User userIterator : [SELECT Id, Profile.Name FROM User WHERE Id =: UserInfo.getUserId()])
{
userProfileSet.add(userIterator.Profile.Name);
}
if( userPermissionList.contains('Test_Permission')== true)
{
relatedListFlag = true;
}
}
public TestController(ApexPages.standardController controller)
{
Custombutton();
}
And also added !not(relatedListFlag) in render property of VF page.
Thanks,
Anish
All Answers
https://help.salesforce.com/articleView?id=custom_perms_overview.htm&type=5
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_permission.htm
http://www.salesforcehacker.com/2014/06/choose-your-own-adventure-with-custom.html
http://www.simplysfdc.com/2014/10/salesforce-custom-permission-for.html
As i have created button in my VF page coding. So i am not able set the custom permission for that. Please let me know any other alternative.
Thanks,
Anish
I used following code and it works for me.
Public Set<String> permissionSetNameList;
Public Set<String> userPermissionList;
Public Set<String> userProfileSet;
Public Boolean relatedListFlag {get;set;}
public void Custombutton()
{
permissionSetNameList =New set<String>();
userPermissionList=New set<String>();
userProfileSet=New set<String>();
for(PermissionSetAssignment permission : [SELECT Id, PermissionSet.Name FROM PermissionSetAssignment WHERE AssigneeId =:UserInfo.getUserId() ])
{
permissionSetNameList.add(permission.PermissionSet.Name);
}
userPermissionList.addAll(permissionSetNameList);
for(User userIterator : [SELECT Id, Profile.Name FROM User WHERE Id =: UserInfo.getUserId()])
{
userProfileSet.add(userIterator.Profile.Name);
}
if( userPermissionList.contains('Test_Permission')== true)
{
relatedListFlag = true;
}
}
public TestController(ApexPages.standardController controller)
{
Custombutton();
}
And also added !not(relatedListFlag) in render property of VF page.
Thanks,
Anish