Prime03 Posted January 5, 2014 Share Posted January 5, 2014 (edited) Hey guys, I've been plowing along with a project I'm working on for work and I'm steps away from the end of it, and I've come to a full stop. I spent the better part of yesterday evening and this morning trying to guess the right way to do this, and I think I'm ready to ask for help. I've got pictures and code to hopefully shine the light. So my previous action involved clicking on a 'Report' button, and at this point a 'Report Viewer' IE window is generated which pretty much looks like a print preview page almost. I need to be able to click on both the Print and Export buttons that are located on the top toolbar, but this is handled by a script event I'm not sure the correct way to trigger it. In the first picture my mouse is hovering over the print button, but AUinfo wants to select the entire toolbar. <script id="arvToolbarClick" language="javascript" for="arv" event="ToolbarClick(Tool)" defer="">if (Tool.ID == 1) { Export(); } else if (Tool.ID == 2) { arv.UseSourcePrinter = true; Tool.Enabled = false; arv.Printer.MaxPage = arv.Pages.Count(); bReturn = arv.Printer.PrintDialog(); if (bReturn) { arv.PrintReport(false); DoOperationsFromClient("print finished"); } Tool.Enabled = true; } //New Function to download Export File from the Server (comes from standard AO_DownLoadFile function) function DownloadFile( relativePath, filename, toBeDeleted, SessionID ) { //debugger; if ( relativePath == null || relativePath == "" ) return; if ( filename == null ) filename = relativePath.substr( relativePath.lastIndexOf('\\') + 1 ); if ( toBeDeleted == null ) toBeDeleted = "no"; //window.open("../Web_Framework/Download.aspx?SessionID=" + SessionID + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted, "_blank" ); var linkObj = opener.top.uploadFrame.document.getElementById("attachment_link"); linkObj.href = "../Web_Framework/Download.aspx?SessionID=" + _GetGlobalVar("SessionID") + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted; linkObj.focus(); linkObj.click(); } //NAT New function to perform Report Export process function Export() { //debugger; var obj = document.getElementById("sessionIDParameter"); var Session = obj.value; obj = document.getElementById("findXMLParameter"); var FindXML = obj.value; obj = document.getElementById("reportNameParameter"); var ReportName = obj.value; var params = new Array( Session, FindXML, ReportName, window ); var res = window.showModalDialog('../form_asp/activereportexport.htm',params,'dialogWidth:300px;dialogHeight:320px;status:no;toolbar:no;scroll:no;center:yes;help:no'); if ( res == null ) return; var FileName = res[0]; //debugger; DownloadFile( FileName, null, "yes" , Session ); }</script> What I've been doing at the moment is creating an object for the Script ID "arvToolbarClick" and trying different arrangement fireEvent, like this for example. WinWait ("Report Viewer: Repair Order Report - Windows Internet Explorer") $oReportWindow = _IEAttach ("Report Viewer: Repair Order Report") $oPrintButton = _IEGetObjById ($oReportWindow, "arvToolbarClick") $oPrintButton.fireEvent("ToolbarClick(Tool)", "1") $oPrintButton.fireEvent("ToolbarClick(Tool)", "1") $oPrintButton.fireEvent("ToolbarClick(Tool)", "1")^ ERROR I'm praying someone can help me out with this before I split my skull open on my desk Edited January 5, 2014 by Prime03 Link to comment Share on other sites More sharing options...
Prime03 Posted January 6, 2014 Author Share Posted January 6, 2014 (edited) So after continuing my search I'm starting to believe I'm approaching this all wrong. I've found a couple threads referring to using 'ScriptControl', or .eval/.execscript, but I'm totally boggled on how to apply it to my situation. There are some examples I've found, but it's just not making any sense to me. I mean, if the script tag I was trying to run was a little less of a brick of code I might have a better chance, but when I look at the script tag I've pulled and some of the other types of examples, I cringe. Here is a more nicely formatted version. expandcollapse popup<SCRIPT id=arvToolbarClick language=javascript for=arv defer event=ToolbarClick(Tool)> if (Tool.ID == 1) { Export(); } else if (Tool.ID == 2) { arv.UseSourcePrinter = true; Tool.Enabled = false; arv.Printer.MaxPage = arv.Pages.Count(); bReturn = arv.Printer.PrintDialog(); if (bReturn) { arv.PrintReport(false); DoOperationsFromClient("print finished"); } Tool.Enabled = true; } //New Function to download Export File from the Server (comes from standard AO_DownLoadFile function) function DownloadFile( relativePath, filename, toBeDeleted, SessionID ) { //debugger; if ( relativePath == null || relativePath == "" ) return; if ( filename == null ) filename = relativePath.substr( relativePath.lastIndexOf('\\') + 1 ); if ( toBeDeleted == null ) toBeDeleted = "no"; //window.open("../Web_Framework/Download.aspx?SessionID=" + SessionID + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted, "_blank" ); var linkObj = opener.top.uploadFrame.document.getElementById("attachment_link"); linkObj.href = "../Web_Framework/Download.aspx?SessionID=" + _GetGlobalVar("SessionID") + "&id=" + relativePath + "&name=" + filename + "&delete=" + toBeDeleted; linkObj.focus(); linkObj.click(); } //NAT New function to perform Report Export process function Export() { //debugger; var obj = document.getElementById("sessionIDParameter"); var Session = obj.value; obj = document.getElementById("findXMLParameter"); var FindXML = obj.value; obj = document.getElementById("reportNameParameter"); var ReportName = obj.value; var params = new Array( Session, FindXML, ReportName, window ); var res = window.showModalDialog('../form_asp/activereportexport.htm',params,'dialogWidth:300px;dialogHeight:320px;status:no;toolbar:no;scroll:no;center:yes;help:no'); if ( res == null ) return; var FileName = res[0]; //debugger; DownloadFile( FileName, null, "yes" , Session ); } </SCRIPT> Edited January 6, 2014 by Prime03 Link to comment Share on other sites More sharing options...
Prime03 Posted January 6, 2014 Author Share Posted January 6, 2014 OK so I get it now! I'm able to execute the Export function, $oReportWindow = _IEAttach ("Report Viewer: Repair Order Report") $oReportWindow.document.parentwindow.execscript("Export()") but unfortunately it's giving me a window that isn't what I would normally use. I still believe I need to access the section regarding Tool.ID = 1 or 2, but these attempts give me an error $oReportWindow.document.parentwindow.execscript("ToolbarClick()", "1") or $oReportWindow.document.parentwindow.execscript("ToolbarClick()") or $oReportWindow.document.parentwindow.execscript("ToolbarClick(1)") I feel so close! Link to comment Share on other sites More sharing options...
Prime03 Posted January 6, 2014 Author Share Posted January 6, 2014 Alright I'm back at it again. I've been inspecting the other script tags that are placing the buttons on the toolbar. The script that is doing this is vbscript. I see reference to the Tool ID being set up here and I'm trying to understand if this can help me. Again, if anyone has any experience with these types of scripts I would really appreciate a push in the right direction. I have 0 vbscript experience and since the part of the javascript tag that calls the local print window has no function title, I don't know how to call either the print or export button. expandcollapse popup<SCRIPT id=arvControlLoaded language=vbscript for=arv defer event=ControlLoaded()> arv.ToolbarVisible = True arv.ToolBar.DisplayToolTips = True arv.ToolBar.Tools.Insert 1, "" arv.ToolBar.Tools.Item(1).Type = 2 'Insert the Export button dim ExportTitle ' astea-trans=text;TXTASP$reportexport_toolbar_vx;N; ExportTitle = "Export..." arv.ToolBar.Tools.Insert 2, "Export" ' astea-trans=text;TXTASP$reportexport_toolbar_vx;N; arv.ToolBar.Tools.Item(2).Caption = "Export..." ' astea-trans=text;TXTASP$export_toolbar_vx;N; arv.ToolBar.Tools.Item(2).Tooltip = "Export" arv.ToolBar.Tools.Item(2).ID = 1 arv.ToolBar.Tools.Item(2).Enabled = False For Each Toolbar in arv.ToolBar.Tools 'MsgBox(Toolbar.Caption) If Toolbar.Caption = "Table Of Contents" Then Toolbar.Visible = False end if If Toolbar.Caption = "&Print..." Then Toolbar.Visible = False arv.ToolBar.Tools.Insert 4, "Print..." arv.ToolBar.Tools.Item(4).ID = 2 arv.ToolBar.Tools.Item(4).Enabled = False ' aastea-trans=text;TXTASP$prnt_t_vx;N; arv.ToolBar.Tools.Item(4).Caption = "Print..." ' astea-trans=text;TXTASP$prnt_t_vx;N; arv.ToolBar.Tools.Item(4).Tooltip = "Print..." end if if Toolbar.Caption = "&Back" then ' astea-trans=text;TXTASP$back_t_vx;N; Toolbar.Caption = "Back" ' astea-trans=text;TXTASP$back_t_vx;N; Toolbar.Tooltip ="Back" end if if Toolbar.Caption = "F&orward" then ' astea-trans=text;TXTASP$forward_vx;N; Toolbar.Caption = "Forward" ' astea-trans=text;TXTASP$forward_vx;N; Toolbar.Tooltip ="Forward" end if Next </SCRIPT> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now