locked
jScript Issues - manipulating ISV toolbar button RRS feed

  • Question

  • Hello,

    Need a little help with this script - I'm manipulating the action performed when an ISV button is pressed. It calls a custom ASPX page that I've designed, which works great, but I'd like to force a save of the form when they push my button before it actually calls the ASPX page. This doesn't seem to work. I've tried to put the original action and the crmForm.Save() command in a different function together as well - that doesn't seem to work at all. This way, the ASPX page still works, but the form isn't saved first.

    Any help? I appreciate it.

    HideTitledButton();
    function HideTitledButton()                
    {  
        /*Narrow down the number of tags returned by only getting the menubar element*/                                           
        var menubarid = "mnuBar1";
        var element = document.getElementById('mnuBar1');
        
        /*Get the li tags from the menubar element. Cycle through the elements in the returned set*/
        var liElements = element.getElementsByTagName('li');                        
        for (var i = 0; i < liElements.length; i++)                        
        {                          
            if (liElements[i].getAttribute('title') == "Close this activity and create another with the remaining allowed minutes.")                            
            {  
                //old onclick: window.execScript(action)
                //old action: openIsvWin('http\x3a\x2f\x2finvoc1\x2fISV\x2fActivitySplit\x2fDefault.aspx',true,'0','', window);
                liElements[i].action = "crmForm.Save(); openIsvWin('http\x3a\x2f\x2fSERVERNAME\x2fISV\x2fActivitySplit\x2fDefault.aspx',true,'0','', window);";
            }                        
        }                                    
    }

    Web: http://invoc.net Blog: http://invoc.net/CRM_BPOS_Blog
    Saturday, February 13, 2010 2:34 AM

Answers

  • Instead of calling the crmForm.Save(); which will force the page to reload before the openIsvWin is called, work around the issue, by opening a new page that tells the form to save and then redirect's to your page.

    The save can be done from the opened window in jscript like this windows.opener.document.crmForm.Save();

    @_Simon_Jackson http://www.simonjackson.info/ MBCS MCBMSS MCBMSP MCSD MCDBA MCAD MCSA
    Monday, February 15, 2010 8:38 AM

All replies

  • Hi,

    1. Did you tried using the very first line of your function to save crmform like

    crmForm.Save();
    //then your other function code

    2. Are you getting any validation prompt or something....????



    Mahain
    Saturday, February 13, 2010 3:35 AM
    Moderator
  • Instead of calling the crmForm.Save(); which will force the page to reload before the openIsvWin is called, work around the issue, by opening a new page that tells the form to save and then redirect's to your page.

    The save can be done from the opened window in jscript like this windows.opener.document.crmForm.Save();

    @_Simon_Jackson http://www.simonjackson.info/ MBCS MCBMSS MCBMSP MCSD MCDBA MCAD MCSA
    Monday, February 15, 2010 8:38 AM