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
Abdul Khatri 7Abdul Khatri 7 

Button on Visual Force page not showing up for some profiles?

I created a visual force page with a button but the button is not visible for certain profiles. Please find the Code below, the "Create Lead" button is not showing up

Can anyone help what is causing this?

<apex:page standardController="Contact" extensions="ContactControllerExtension">
    <apex:form >
        <apex:pageBlock id="in" title="New for: {!Contact.Name} ">
            <apex:pageblockSection title="New Lead" columns="1">
                <apex:outputField value="{!Contact.Field1}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field2}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field3}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field4}" rendered="false"/>                
            </apex:pageblockSection> 
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Create}" value="Create Lead" />
                <apex:commandButton action="{!Cancel}" value="Cancel" />                      
            </apex:pageBlockButtons>                                       
        </apex:pageBlock>
    </apex:form>    
</apex:page>
SalesFORCE_enFORCErSalesFORCE_enFORCEr
As you are using the Contact standard controller and standard Create button action, the profiles which don't have create access on Contact object will not be able to see this button.

Please mark it Best Answer if it helps.
Abdul Khatri 7Abdul Khatri 7
I also thought the same way but that is not the case actually the profile you can see the button has less permissions on the Contact object than the one who can't see it which is more confusing. Sorry your thoughts didn't resolve my issue but I appreciate your feedback.

Any other thought?
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Are you able to create contact directly as a user who can;t see that custom button?
Abdul Khatri 7Abdul Khatri 7
I think the thought that we were drilling was right but couldn't pin point issue area which I got it solve by change the action of the button "Create" to "CreateLead" Here is the latest code with bold highlighted

<apex:page standardController="Contact" extensions="ContactControllerExtension">
    <apex:form >
        <apex:pageBlock id="in" title="New for: {!Contact.Name} ">
            <apex:pageblockSection title="New Lead" columns="1">
                <apex:outputField value="{!Contact.Field1}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field2}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field3}" rendered="false"/>                
                <apex:outputField value="{!Contact.Field4}" rendered="false"/>                
            </apex:pageblockSection> 
            <apex:pageBlockButtons >
                <apex:commandButton action="{!CreateLead}" value="Create Lead" />
                <apex:commandButton action="{!Cancel}" value="Cancel" />                      
            </apex:pageBlockButtons>                                       
        </apex:pageBlock>
    </apex:form>    
</apex:page>

Thanks. I will still make your answer the best one.