Passing Parameters in both FireFox and IE

I'm trying to pass a value from one Admin form into another and it must work in both FireFox and IE. 

 

Using the window.showModalDialog(url, myVariable, settings) and the corresponding myVaribale=window.dialogArguments works with IE but not in FF (the window opens but the variable is "undefined")

 

Using the web client configuration documentation to specify the filter parameters in the URL and then using window.open works partially in FF (only part of the form is updated based on the filter for some reason) but I get a "Failed to read attachment" error in IE.  

 

Does anyone have a solution?   I've tried multiple variations of window.open which seems most promising but haven't found a magic formula. 

 

Thanks!!

Tagged:

Comments

  • showModalDialog will only work in IE. It's not clear what the relationship is between your Admin forms but have you thought of using Cookies to write out values from one form and read them from the other?

  • Yes, I figured out the showmodalDialog limitation (frustrating) .   The one Admin form is a search and then (in theory) the user can select a line from the results and open the second Admin form that has more details on the item selected.  

     

    I'd be open to any solution, cookies included, but I'm not really a programmer so would need more explicit instructions to try.

     

    Thanks!

  • The cookie solution is not too tricky to impliment once you get your head around it.

     

    The 'launching' form needs a VBScript and a Jscript. Put a button on the admin form which runs the NewCookie script when pressed. The script reads data from fields on the form, stores it in a cookie then launches the target form.

     

    First - the VBScript:

    function NewCookie()
    ' First Create a string of text from the fields you want to pass across
    ' Fields are delimited by !! but this can be anything which does not appear in the data
        Dim AdminCookie
        AdminCookie = "!!" & GetField("Field1")
        AdminCookie = AdminCookie & "!!" & GetField("Field2")
        AdminCookie = AdminCookie & "!!" & GetField("Field3")
        AdminCookie = AdminCookie & "!!" & GetField("Field4")& "!!"

     ' Next line calls the SaveCookie function which is defined below
        SaveCookie "AdminCookie", AdminCookie

     ' Next line calls a JScript function which actually launches the admin form
        Call OpenAdminForm()
    End function

    function SaveCookie(VarName,VarValue)
        If len(VarValue) >= 1 Then
            Document.Cookie = VarName & "=" & VarValue & ";" &  "expires=" & Date()+1
        Else
            Call Delete_Cookie(VarName)
        End If
    End function

     

    Next the JScript which is called from the above:

    // Launches the admin form
    function OpenAdminForm()
    {
    var LaunchURL
    LaunchURL = "http://ServerName/Metastorm/eForm.aspx?Map=Admin-Form-Group-Name&Client=External&Action=Admin-Form-Name"
    window.open(LaunchURL,'_blank','resizable=yes,scrollbars=yes');

    }

     

    The 'target' form needs some JScript which will read the cookie from disk whenever it loads. On this form call the function ReadCookie from the on form load property.

     

    // Read Cookie details
    function ReadCookie()
    {
    // This line populates a variable called AdminCookie with the contents of the cookie read by the GetCookie function below
        var AdminCookie = GetCookie("AdminCookie");

    // If the cookie is found the next section splits it into an array of fields using the !! delimiter
    // then sets fields on the admin form accordingly.
        if (AdminCookie || 0) {
        var AdminDataArray;
            AdminDataArray = AdminCookie.split( "!!");

        SetField("Field1", "Value", AdminDataArray[1]);
        SetField("Field2", "Value", AdminDataArray[2]);
        SetField("Field3", "Value", AdminDataArray[3]);
        SetField("Field4", "Value", AdminDataArray[4]);

     

    // Finally call the delete cookie function to clear the cookie 
        delete_cookie("AdminCookie","");
    }
    }

    // This function actually reads the cookie in from disk.

    function GetCookie(name) {
        var cookie = " " + document.cookie;
        var search = " " + name + "=";
        var setStr = null;
        var offset = 0;
        var end = 0;
        if (cookie.length > 0) {
            offset = cookie.indexOf(search);
            if (offset != -1) {
                offset += search.length;
                end = cookie.indexOf(";", offset)
                if (end == -1) {
                    end = cookie.length;
                }
                setStr = unescape(cookie.substring(offset, end));
            }
        }
        return(setStr);
    }

     

    //This function deletes the cookie.

    function delete_cookie (name, path)
    {
        var expiration_date = new Date ();
        expiration_date.setYear (expiration_date.getYear () - 1);
        expiration_date = expiration_date.toGMTString ();

        var cookie_string = escape (name) + "=; expires=" + expiration_date;
        if (path != null)
            cookie_string += "; path=" + path;

        document .cookie = cookie_string;
    }

     

    Hope this is helpful

    Rick.

     

  • Thanks for the details.   I tried it and get nothing in FF and in IE, I still get the "Failed to read attachment" error.  I put in a couple msgboxes in the "NewCookie" section which report back correctly in IE but I literally get nothing in FF.   Since I'm pulling from a grid, I'm using the "eworkGetCurrentRow" and "eworkGetCell" and thought that might be an issue but as I said, it reports back correctly in IE.

     

    Any further suggestions?  Thanks!!!

  • Turns out the VB script is not supported in 9.1.   So I solved this using the status field in the toolbox and set it up so it drilled down to the Admin form I wanted to open and setup parameters as normal.    Worked on the first try!!  and works in both IE and FF.   

  • jm_aussie.

     

    For ref from experience you usually get the failed to read attachment error if during client script you try to link to another form via window.open without using the full path http:// address. So linking to "eForm.aspx?...." instead of http://servername/metastorm/eForm.aspx?.....

     

    This error is pretty intermittent also. Some of the times it works fine with just the "eForm.aspx" reference for ages, then you do a deployment without any changes to even that piece of code and it will stop working altogether. 

     

    I've done almost exactly what you were looking to do also in another way, and without using cookies, which I'm presently trying to document. I'll try to post it up here just in case you wanted to see an alternative solution.