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
Lakshmi SLakshmi S 

How to hide save and cancel button in custom detail page?

Hi Team,
How to hide save and cancel button in custom detail page?
<apex:pageBlockButtons >
                
                <apex:commandButton value="Save" action="{!Save}" id="saveButton" />
              <!--  <apex:commandButton value="Save & New" action="{!saveNew}"/> -->
                <apex:commandButton value="Edit" action="{!Edit}" id="editButton" />
                <apex:commandButton value="Delete" action="{!Delete}" onclick="if(!confirm('Are you sure?')){return false};" id="deleteButton" />
                <apex:commandButton value="Clone" action="{!doClone}" id="cloneButton" />
               <apex:commandButton value="Cancel" action="{!doCancel}" id="cancelButton" immediate="true" />
            </apex:pageBlockButtons>

Please let me know how can we do this in visualforce page...

Thanks.
Lakshmi.
 
Steven NsubugaSteven Nsubuga
Use the rendered attribute
<apex:pageBlockButtons >
                
                <apex:commandButton value="Save" action="{!Save}" id="saveButton" rendered="{!someBoolean}"/>
              <!--  <apex:commandButton value="Save & New" action="{!saveNew}" /> -->
                <apex:commandButton value="Edit" action="{!Edit}" id="editButton"rendered="{!someBoolean}" />
                <apex:commandButton value="Delete" action="{!Delete}" onclick="if(!confirm('Are you sure?')){return false};" id="deleteButton" rendered="{!someBoolean}"/>
                <apex:commandButton value="Clone" action="{!doClone}" id="cloneButton" rendered="{!someBoolean}"/>
               <apex:commandButton value="Cancel" action="{!doCancel}" id="cancelButton" immediate="true" rendered="{!someBoolean}" />
            </apex:pageBlockButtons>

 
Jack Yu@TokyoJack Yu@Tokyo
Hi  Lakshmi S

【Step 1. get the inline parameter】
You can add code below to your Apex code to know Visualforce page is viewed in custom detail page or not.

System.debug('ApexPages.currentPage().getUrl()----->' + ApexPages.currentPage().getUrl());

   【in custom detail page】
   ApexPages.currentPage().getUrl()----->/apex/PictureSlideshow?id=a007F00000EwQur&inline=1     
    ←←←  Parameter: inline . Yes, you can get this parameter (inline) to detect .  if inline is 1


   【not in custom detail page】
    ApexPages.currentPage().getUrl()----->/apex/PictureSlideshow?id=a007F00000EwQur
    ↑↑↑ Without inline parameter. 


【Step 2. hidden your button by rendered property】
since you got parameter inline , and then you can set your button is show or not by rendered property