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
CHENNA$A@CHENNA$A@ 

Override button in related list

Hi All,

 

I need to Hide the standard button & edit/del of that particualr quote under the oppy related list on check of an checkbox.

 

 

Thanks,

Chenna(india)

Best Answer chosen by Admin (Salesforce Developers) 
wajidawajida

I dont know about doing this using javascript but I have listed below a VF page that displays the quote related list without the new or edit button the code is listed below

 

public class HideQuote {
   public opportunity opp;
   public pagereference oppdetail;
    public boolean hideorshow;

public HideQuote(ApexPages.standardcontroller con){
   Id id = apexpages.currentpage().getparameters().get('id');
    opp = (id== null)? new opportunity():[select id, name, stagename, closedate, show_quote__c from opportunity where id = :apexpages.currentpage().getparameters().get('id')];

 hideorshow = opp.show_quote__c;
    }
     public boolean getShowQuote(){
     return hideorshow;
       
}  

public pageReference save(){
      oppdetail = new ApexPages.StandardController(opp).view();    
      upsert opp;
      oppdetail.setRedirect(true);
       return oppdetail;
        }   
      }

 

 

<apex:page standardController="opportunity" extensions="HideQuote">
   <apex:pageBlock >     
     <apex:pageBlockSection >
       <apex:detail subject="{!opportunity}" relatedList="false"/>
      </apex:pageBlockSection>
        <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="opportunityLineItems" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="notesandattachments" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="opportunitycontactroles" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="quotes" rendered="{!ShowQuote}"/>
         </apex:pageBlockSection>
        </apex:pageBlock>         
      <apex:pageBlock title="Quotes" rendered="NOT{!showquote}">
       <apex:pageBlockTable value="{!opportunity.quotes}" var="q" >
          <apex:column >
             <apex:facet name="header">Name</apex:facet>
             <apex:outputField value="{!q.name}"/>         
          </apex:column>
           <apex:column >
             <apex:facet name="header">Status</apex:facet>
             <apex:outputField value="{!q.status}"/>         
          </apex:column>
           <apex:column >
             <apex:facet name="header">Total Price</apex:facet>
             <apex:outputField value="{!q.totalprice}"/>         
          </apex:column>    
       </apex:pageBlockTable>
    </apex:pageBlock> 
</apex:page>

 

I have used a show_quote__c custom checkbox field on opportunity to determine whether quotes are shown or not. This is not a very elegant solution and If you can think of something better go ahead and do it. and let me know

All Answers

imutsavimutsav
go to setup -> Customize -> Quotes-> Buttons and Links -> now click edit next to 'New Quote' and Edit/Delete.

Thanks
Utsav
[Do mark this answer as solution if it works for you and give a kudos.]
CHENNA$A@CHENNA$A@

Sorry. I need to hide not override.

imutsavimutsav
that is simple you need to go to the Opportunity page layout. Then scroll down to the Quote related list section and then click on the screwdriver. from this new popup window click on the '+' sign next to button. Now uncheck the button next to 'New Quote'. Click save and then save the page layout.

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
imutsavimutsav
Remember you can only remove edit/delete link next to the Quote in the related list only if you take the edit/delete access for that user/profile.

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
CHENNA$A@CHENNA$A@

I don't want to hide the new quote button completely. I am having checkbox field, If checkbox ="true" then i need to hide "new quote" button & Edit/Del" also.

imutsavimutsav
I suppose you have this checkbox on your Opportunity Object. If thats the case then you have to create a VF page which would list all the Quotes instead of using the Quote related list. This would give you the capability of hiding/ showing the links based on the checkbox field. In the constructor of this VF page you would check if the check box is selected and based on that you would render the button and/or edit/delete links.

Thanks
Utsav
[Do mark this answer as solution if it works for you and give a kudos.]
CHENNA$A@CHENNA$A@

Yup. I know we can do by custom code. Is there a way,  we can do by using the homepage components or writing the javascript to do this task. Thanks for prompt suggestions man

imutsavimutsav
This is the only solution I can think of right now.

Thanks
Utsav
wajidawajida

I dont know about doing this using javascript but I have listed below a VF page that displays the quote related list without the new or edit button the code is listed below

 

public class HideQuote {
   public opportunity opp;
   public pagereference oppdetail;
    public boolean hideorshow;

public HideQuote(ApexPages.standardcontroller con){
   Id id = apexpages.currentpage().getparameters().get('id');
    opp = (id== null)? new opportunity():[select id, name, stagename, closedate, show_quote__c from opportunity where id = :apexpages.currentpage().getparameters().get('id')];

 hideorshow = opp.show_quote__c;
    }
     public boolean getShowQuote(){
     return hideorshow;
       
}  

public pageReference save(){
      oppdetail = new ApexPages.StandardController(opp).view();    
      upsert opp;
      oppdetail.setRedirect(true);
       return oppdetail;
        }   
      }

 

 

<apex:page standardController="opportunity" extensions="HideQuote">
   <apex:pageBlock >     
     <apex:pageBlockSection >
       <apex:detail subject="{!opportunity}" relatedList="false"/>
      </apex:pageBlockSection>
        <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="opportunityLineItems" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="notesandattachments" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="opportunitycontactroles" rendered="true"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection >
         <apex:relatedList subject="{!opportunity}" list="quotes" rendered="{!ShowQuote}"/>
         </apex:pageBlockSection>
        </apex:pageBlock>         
      <apex:pageBlock title="Quotes" rendered="NOT{!showquote}">
       <apex:pageBlockTable value="{!opportunity.quotes}" var="q" >
          <apex:column >
             <apex:facet name="header">Name</apex:facet>
             <apex:outputField value="{!q.name}"/>         
          </apex:column>
           <apex:column >
             <apex:facet name="header">Status</apex:facet>
             <apex:outputField value="{!q.status}"/>         
          </apex:column>
           <apex:column >
             <apex:facet name="header">Total Price</apex:facet>
             <apex:outputField value="{!q.totalprice}"/>         
          </apex:column>    
       </apex:pageBlockTable>
    </apex:pageBlock> 
</apex:page>

 

I have used a show_quote__c custom checkbox field on opportunity to determine whether quotes are shown or not. This is not a very elegant solution and If you can think of something better go ahead and do it. and let me know

This was selected as the best answer