function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc development hintssfdc development hints 

hi

i have a command link called as delete in my vf page , for which i need to have the delete link visible only for system admin and not for other users, how do i restrict that

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference.

 

=====VF=======

<apex:page controller="getProfileuser" >

<apex:form >

Submit Here

<apex:commandLink value="Delete" rendered="{!bool}"/>

</apex:form>

</apex:page>

=======Apex Controller=======

 

public class getProfileuser {

 

    public boolean bool { get; set; }

    public getProfileuser()

    {

        Profile ProfileName = [select Name from profile where id = :userinfo.getProfileId()];

        system.debug('_______ProfileName ____'+ProfileName );

        if(ProfileName.Name=='System Administrator')

        {

        bool=true;

        }

        else

        {

            bool=false;

        }

    }

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.