Trigger Print Preview after MtlTags form is opened

I am trying to write a customization that will automatically print preview when the Print Tags form is opened. I already have a customization that opens Print Tags automatically after clicking OK on End Activity. It would be great if the operator didn’t have control over which report style to use, and didn’t have to hit Print Preview.

Using a DataView I have been able to set the ReportStyleNum automatically, but there doesn’t appear to be any way to trigger the Print Preview action from there.

I have seen a lot of threads that describe how to add buttons to forms (e.g. Order Entry, Job Traveler) to print reports directly, which could work in this case. It appears that a lot of parameters need to be specified directly, which doesn’t seem to be necessary in this case. The MtlTagsRpt is already open and has the necessary parameters loaded or can have them loaded using the DataView (e.g. the ReportStyleNum as mentioned above).

When I try to set it up like the threads describe, I have issues with using SubmitToAgent. It appears I need an adapter to make this work, but I am not sure what adapter to use for MtlTags.

The error is as follows: “‘Script’ does not contain a definition for ‘SubmitToAgent’ and no extension method ‘SubmitToAgent’ accepting a first argument of type ‘Script’ could be found (are you missing a using directive or an assembly reference?)”

Here is my code:

var session = (Ice.Core.Session)oTrans.Session;
							edvReportParam.dataView[edvReportParam.Row]["AutoAction"] = "Preview";
							edvReportParam.dataView[edvReportParam.Row]["AgentID"] = "SystemTaskAgent";
							edvReportParam.dataView[edvReportParam.Row]["ReportStyleNum"] = "1026";
							edvReportParam.dataView[edvReportParam.Row]["WorkstationID"] = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Session)oTrans.Session);
							edvReportParam.dataView[edvReportParam.Row]["PrinterName"] = "PDF";
							this.SubmitToAgent("SystemTaskAgent", 0, 0, "Epicor.Mfg.UIRpt.MtlTags.dll");

Is there a simpler way?

I believe the following code is the key to getting this to work:

varReport.SubmitToAgent(varDS, “SystemTaskAgent”, 0, 0, Erp.UIRpt.MtlTags);

The trouble I am having is defining “varReport” and “varDS”. I have read through the following threads, but am still stuck.

The above threads all involve setting the report parameters from scratch. Since the MtlTags form has already loaded with the parameters/dataset needed to run the report (except for the correct ReportStyleNum, which can be set with a DataView), it should just be a matter of calling those stored parameters for SubmitToAgent?