At the moment I have a button placed on my Opportunities page which opens a popup, on my sendRequest() function this popup is closed. What I would like to do is further improve this function to also display a message on top of the parent window (maybe in the location and format validation errors are shown). How can I achieve this?

Button JS (to open popup) on main window:

popup = window.open("apex/RequestPage?id={!Opportunity.Id}", "newPopup", "width=620,height=600, scrollbars=no, location=no"); 

RequestPage popup:

<apex:page standardController="Opportunity" extensions="myExtension" showHeader="false" sidebar="false">
    <apex:form >
        <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Send Request" action="{!sendRequest}" />

sendRequest() function (in controller extension):

  public PageReference sendRequest()
      // do some stuff here and then close window...
      return new PageReference('javascript:window.close()'); 

  • This is all custom? You have opened a popup and the method above references the controller for this popup? A little more code would help. Sep 8, 2014 at 1:49
  • @CaspNZ Please check updated post Sep 8, 2014 at 10:34
  • It might be possible if your Opportunity page was also custom. Unfortunately, I don't have a quick solution for this one. Sep 8, 2014 at 17:30

1 Answer 1


Here's a bit of a hack that may work for your use case (Using standard Opportunity detail page rather than VF page).

  1. Add to your Opportunity three fields: Alert__c (formula), Alert_text__c, and Last_popup_datetime__c
  2. The Alert__c formula displays alert_text__c but only if NOW() < last_popup_dateTime__c plus some number of seconds (you decide)
  3. Place Alert__c in a section at the top of your Opportunity layout without showing title in either edit or view pages
  4. Have your popup controller method save the value to show in Alert_text__c and set the value of last_popup_datetime__c to DateTime.now(). Be sure to Save the Opportunity with DML or a redirect to the standardController.save() action function

So, the effect you get is a transitory message appearing at the top of the detail page where the lifetime of the message is controlled - if the 'alert' needs to persist for an hour, no problem, if it needs to persist only for 30 seconds, no problem. Of course the logic to make it disappear won't execute until the next page refresh.

There is a related discussion of soft alerts here

  • Although this does answer the question, I was hoping for a more alert type of message to be displayed. I'm afraid this work around (which is good) simply wont be prominent enough. I may mark this as the answer as I believe there just simply isnt a function built within Salesforce for this. Sep 9, 2014 at 9:53
  • 1
    There are icons you can use in the image formula that are larger than in my example that cause the 'alert' to get more attention - perhaps that might help.
    – cropredy
    Sep 9, 2014 at 14:25

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.