Close form on Save

Comments

4 comments

  • Avatar
    Loren Bratzler

    Michael,

    I think you can do what you are trying to do like this:

    Create a simple JavaScript function to close the active window:

    function closeWindow()
    {
       window.close();
    }

    From what I have read and from my testing, the default behavior is that the window.close command will only close the current active tab in your browser.

    Create your Custom Button:

    Configure your button to do a "Save" Action:

     

    Then on the Advanced tab, tell it to execute the JavaScript function:

     

    I did a quick test of this and it seemed to work fine.  I changed some data on a textbox in the form and then when I clicked the "Save & Close" button, my changes to the textbox value were saved in the process schema and the browser tab closed.

    1
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    One caveat:  You may need to test this in multiple browsers.  For me it worked fine in Internet Explorer and Chrome but did not work in FireFox.  In FireFox, it closed the tab but the update to the Text Box did not get saved.

    0
    Comment actions Permalink
  • Avatar
    Michael Barath

    Thanks Loren. Works like a charm. You're right about browsers. For a while I thought the browser wars were over but no such luck. At least we're not using Netscape Navigator. 

    0
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    It was bugging me about why this did not work in Firefox.  It seemed like the window was closing before the Save action could occur.  So I modified the JavaScript function to add a 100 millisecond delay before it executes the close command like this:

    function closeWindow()
    {
        setTimeout(function() {
            window.close();
        }, 100);
    }

    And now it does work in Firefox!

    0
    Comment actions Permalink

Please sign in to leave a comment.