Print list of invoices through custom code

Hi I am trying to print invoices through custom code that is triggered througha Print Button on a UD40 command. I am able to get the invoice I want with the correct report and report style into the System Agent. No errors occur; the status says complete; it shows up in the “Reports” tab of the System Monitor; the only issue is it will not print. If I select the line in question in the System Monitor and click print it will print to the correct printer. I am a little lost on where I am going wrong. I have taken the AR invoice report parameters from a trace. Here is my code:

private void btnPrint_Click(object sender, System.EventArgs args)
{
string batch = GetList();
int invoiceNum = 0;
if(batch != “”)
{
invoiceList = batch.Split(’,’);
}
else
{
EpiMessageBox.Show(“No invoices input”);
return;
}

	for(int i = 0; i < invoiceList.Length; i++)
	{
		invoiceNum = Int32.Parse(invoiceList[i]);
		PrintRoutine(invoiceNum);
	}
	
	EpiMessageBox.Show("Printing has started");
	oTrans.PushDisposableStatusText("Reports Printing at " + printer + "...", false);			
}

public void PrintRoutine(int invNum)
{
	string strTaskAgent = "";
	//Task Agent	
	SysAgentAdapter adSysAgent = new SysAgentAdapter(this.oTrans);
	adSysAgent.BOConnect();
	adSysAgent.GetDefaultTaskAgentID(out strTaskAgent);
	adSysAgent.GetByID(strTaskAgent);
	//ARInv Form Adapter	
	ARInvFormAdapter adARInvForm = new ARInvFormAdapter(this.oTrans);
	adARInvForm.BOConnect();
	adARInvForm.GetDefaults();
	adARInvForm.GetNewParameters();	
	//Grab Dataset
	ARInvFormDataSet dsARForm = adARInvForm.ReportData;
	ARInvFormDataSet.ReportStyleDataTable tblReportStyle = (ARInvFormDataSet.ReportStyleDataTable)adARInvForm.ReportData.Tables["ReportStyle"];
	ARInvFormDataSet.ARInvFormParamDataTable tblParams = (ARInvFormDataSet.ARInvFormParamDataTable)adARInvForm.ReportData.Tables["ARInvFormParamData"];
	ARInvFormDataSet.ARInvFormParamRow arInvParamRow = (ARInvFormDataSet.ARInvFormParamRow)adARInvForm.ReportData.Tables["ARInvFormParam"].Rows[0];
	arInvParamRow["InvoiceNum"] = invNum;
	arInvParamRow["ArchiveCode"] = 0;
	arInvParamRow["AutoAction"] = "SSRSClientPrint";
	arInvParamRow["AgentID"] = "SystemTaskAgent";
	arInvParamRow["SysRowID"] = Guid.Parse("00000000-0000-0000-0000-000000000000");
	arInvParamRow["ReportStyleNum"] = 1020;
	arInvParamRow["PrinterName"] = printer;	
	//arInvParamRow["RptPrinterSettings"] = "PrinterName=\"" + printer + "\""+ ",Copies=1,Collate=True,Duplex=Simplex,FromPage=1,ToPage=0";
	arInvParamRow["SSRSEnableRouting"] = false;
	arInvParamRow["RecurringTask"] = false;
	arInvParamRow["DateFormat"] = "m/d/yyyy";
	arInvParamRow["NumericFormat"] = ",.";
	arInvParamRow["ReportCurrencyCode"] = "USD";
	arInvParamRow["ReportCultureCode"] = "en-US";
	arInvParamRow["SSRSRenderFormat"] = "PDF";
	arInvParamRow["TaskNote"] = "System Generated";

	ARInvFormDataSet.ReportStyleRow arReportStyleRow = null;
	if(adARInvForm.ReportData.Tables["ReportStyle"].Rows.Count == 0)
	{
		arReportStyleRow = tblReportStyle.NewReportStyleRow();
		arReportStyleRow["StyleNum"] = 1020;
	}
	else
	{
		arReportStyleRow = (ARInvFormDataSet.ReportStyleRow)adARInvForm.ReportData.Tables["ReportStyle"].Rows[0];
	}
	arReportStyleRow["ReportID"] = "ARForm";
	arReportStyleRow["StyleDescription"] = "PNY AR Invoice SSRS with APRII";
	arReportStyleRow["RptTypeID"] = "SSRS";

	if(adARInvForm.ReportData.Tables["ReportStyle"].Rows.Count == 0)
	{
		tblReportStyle.AddReportStyleRow(arReportStyleRow);
	}
	adARInvForm.SubmitToAgent("SystemTaskAgent", 0, 0);
	
	arReportStyleRow = null;
	arInvParamRow = null;
	adARInvForm = null;
	adSysAgent.Dispose();
	adSysAgent = null;
}

Any help is appreciated! Thanks!

I solved my issue. Evidently the the “WorkStationID” is important to the system agent to print. I had left this out.