currently i have a button that will update the account based on an outbound message workflow. I dont want everyone to have access to this button, but i also do not want to create another page layout just to hide this button. I was told i can code something in my visualforce page to only show this button to certain users.
public class my class{
public Boolean button { get; set; }
public myclass{
String profileName=[Select p.Name From Profile p where p.id=:UserInfo.getProfileId()].Name; button = (profileName=='profile u wanna give permission')?true:false;
}
}
in your page:
<apex:commandButton rendered="{!button}" value="test" action ="{!Execute}"/>
String profileName=[Select p.Name From Profile p where p.id=:UserInfo.getProfileId()].Name; button = (profileName=='profile u wanna give permission')?true:false;
can you be more specific?
If its a button on visual force page u can use "Rendered " Tag to dynamically render the button based on the login user profile.
currently i have a button that will update the account based on an outbound message workflow. I dont want everyone to have access to this button, but i also do not want to create another page layout just to hide this button. I was told i can code something in my visualforce page to only show this button to certain users.
Would the first piece be a seperate class from the one that i already have that executes the button? or will i or can i add it to the existing?
no need for another class
Add it to your existing class n try
i have written this code as an example
public Boolean button { get; set; } // variable
String profileName=[Select p.Name From Profile p where p.id=:UserInfo.getProfileId()].Name; button = (profileName=='profile u wanna give permission')?true:false;
add the above two lines in your constructor