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
Tyler Ball 1Tyler Ball 1 

How to override standard new quote button

My goal is to override the standard new quote button so that the expiration date on the quote defaults to today()+30. I don't want to use a workflow to accomplish this since I want the default expiration date to appear before the user saves the quote. I started creating the following visualforce page:

<apex:page standardController="Quote" showHeader="False" action="/0Q0/e?ExpirationDate={!TODAY()+30}
&oppid=006Z0000008JgXv">
</apex:page>

I got stuck because I don't know how to set the oppid to autopopulate with the associated opportunity id. I've just manually entered a static oppid  to test with. Does anyone know how I would modify this code to populate the associated opportunity id automatically? 
SaiGSaiG

Hi Tyler, 

Is this on a standard page or VF page? May be this blog post could be helpful to you:

http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html

Thank you,

Sai

Tyler Ball 1Tyler Ball 1
I'm overriding a standard page with a VF page. 
Vinit_KumarVinit_Kumar
Create custom button on Quote with following attributes :-

Behavior :  Execute JavaScript

Display Type Detail page Button

and put the below in JS code 
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

getMsg(); 
function getMsg() { 

newwindow=window.open('apex/<your page name>?oppid={!Quote.Opportunity}','HI','height=500,width=550'); 
if (window.focus) {newwindow.focus()} 
return false; 
}

If this helps,please mark it as best answer to help others :)

Tyler Ball 1Tyler Ball 1
I get an error that says "Field Quote.Opportunity does not exist". 
Vinit_KumarVinit_Kumar
My Bad Tyler, 

try this one :-

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

getMsg(); 
function getMsg() { 

newwindow=window.open('apex/<your page name>?oppid={!Opportunity.Id}','HI','height=500,width=550'); 
if (window.focus) {newwindow.focus()} 
return false; 
}

If this helps,please mark it as best answer to help others :)
Tyler Ball 1Tyler Ball 1
Vinit, I'm not sure that this accomplishes what I'm trying to do. I'd like to be able to create a "New Quote" button which will automatically populate the expiration date of the quote to today()+30. The button would be located on the quotes related list which is located on the opportunity object. 
Vinit_KumarVinit_Kumar
Yes,

This would open the VF page you created,as you want this on the related list of Opportunity.

Then,you need to create a List button on Quote instead of Detail page button.
Tyler Ball 1Tyler Ball 1
I already have a custom button on the Quotes related list that overrides the standard quote creation page with my VF page . The problem is that I don't know how to reference the opportunity id from within the VF page. If I use a static opportunity id (e.g. 006Z0000008JgXv) like I did in the code below, the page pulls up fine. However, I need to dynamically pull the oppid from the opportunity somehow. I don't know how to do that. If I modify the code below to say "oppid={!opportunity.id} I get an error saying "unknown property 'QuoteStandardController.opportunity'". I'm probably just going about this all wrong...

<apex:page standardController="Quote" showHeader="False" action="/0Q0/e?ExpirationDate={!TODAY()+30}
&oppid=006Z0000008JgXv">
</apex:page>
Vinit_KumarVinit_Kumar
Yes,

Like I said create a custom button which will open the VF page and use the merge fields which I suggested you to populate the Opportunity Id.

Hope this helps !!
Elisabeth DoserElisabeth Doser
I am overriding New Quote using the standardcontroller to expose the full functionality of the CKEditor (namely spell check). I have a couple issues. First, when I click New Quote from the Quotes related list, the Opportunity name appears but the Account name does not (the label does appear). Here are the inputFields I've defined. 

 <apex:inputField value="{!Quote.AccountID}"> </apex:inputField>
  <apex:inputField value="{!Quote.OpportunityID}"> </apex:inputField>

Second, the Opportunity is field being displayed as a lookup. I really want to keep the standard functionality on New Quote that prohibits changing Account or Opportunity when clicking New quote.

I've also overriden Edit to the same VF page. When I open an existing Quote, both values appear in the page properly.

Any suggestions would be greatly appreciated.