On opportunity there is a button called submit bid request , so this button is only visible/enable when the stage is changed to closed won I am trying to write a trigger so please give me some nice suggestions how can i achieve this.

  • What do you want to do with your trigger ? Currently the question is not very clear, can you add more detail? – Samuel De Rycke Mar 6 '14 at 10:55
  • on opportunity a custom button is there its name is submit bid request , on the opportunity page it is visible only when the stage status is changed to closed won after only that we can submit the bid. – user7201 Mar 10 '14 at 5:43

An alternative is to do the following:

  1. Have two record types, 'Open' and 'ClosedWon'
  2. When Opportunity.stagename becomes closed won, use a workflow to change the recordtype from 'Open' to 'ClosedWon' (actually, you change the recordTypeId)
  3. Have two page layouts - one for Open Oppos, one for closedWon oppos
  4. The ClosedWon Oppo page layout contains the submit bid button, the "open" Oppo page layout does not include the submit bid button

All point and click configuration


If you are using custom buttons on a page layout, you cannot hide or disable them conditionally based on record's values. But you can use Javascript to check field values and perform different actions.

Try using "OnClick Javascript" as content source for your custom button, and put something like this in the button's content:

if ({!ISPICKVAL(Opportunity.StageName, 'Close/Won')}) {
  //... Submit bid request action
else {
  alert("You cannot submit bid request if opportunity stage is not Close/Won");

If I got what you want, there is nothing to do with trigger. Instead in the document.ready() event of the VF page which has your submit bid request button, check the stage of the opportunity. Then disable/hide the button with JQuery or JavaScript based on the stage.
Else you can get the opportunity stage from your controller and there you can set a flag that will be initialized based on the opportunity stage.

Here is a guidance how to use controllers if you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.