Print invoice from dashboard with custom code

Hi guys i have the code below running on a dashboard. I have the similar code for print preview where AutoAction = “printpreview” and it works, but AutoAction = “print” command it is generating this error in the task agent “Expected AutoAction to be either print, preview or generate”. Also i tried AutoAction = “SSRSClientPrint” and is not printing either. please help

private void PrintInv(string invoicenum)
{

// Provide print dialog support
ARInvFormDataSet ds = new ARInvFormDataSet();
var session = this.oTrans.CoreSession;

ds = boARInvForm.GetNewParameters();
boARInvForm.GetRptArchiveList();
boARInvForm.GetDefaults(ds);


// Params that need setting

ds.ARInvFormParam[0].InvoiceNum = Convert.ToInt32(invoicenum);
ds.ARInvFormParam[0].AutoAction = "PRINT";
ds.ARInvFormParam[0].AgentSchedNum = 0;
ds.ARInvFormParam[0].AgentID = "SystemTaskAgent";
ds.ARInvFormParam[0].RecurringTask = false;
ds.ARInvFormParam[0].DateFormat = "m/d/yyyy";
ds.ARInvFormParam[0].NumericFormat = ",.";
ds.ARInvFormParam[0].ReportStyleNum = 1009;
	
ds.ARInvFormParam[0].WorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID(session);
ds.ARInvFormParam[0].ReportCultureCode = Ice.Lib.Report.EpiReportFunctions.GetRptCultureCode(session);
ds.ARInvFormParam[0].ReportCurrencyCode = Ice.Lib.Report.EpiReportFunctions.GetRptCurrencyCode(ds.Tables[0].Rows[0]["ReportCultureCode"].ToString(), session);
ds.ARInvFormParam[0].SSRSRenderFormat = "PDF";
ds.ARInvFormParam[0].SSRSEnableRouting = false;
boARInvForm.SubmitToAgent(ds, "SystemTaskAgent", 0, 0, "Erp.UIRpt.ARInvForm;" + "ARForm");
}

Just a shot in the dark. Have you tried print in lowercase? Is there a setting to specify whether the printer is client or server? I know when you go through the UI you have to specify which printer before anything happens.

i tried lower case yes and the printr since it will be the default printer of the user i didnt specified the parameter PrinterName. Any other idea?

Another long shot. But when I did a trace on the print action when I go through the UI, I found a block with a WHERE clause that had values of ‘AUTOPRT’ and ‘AUTOPRV’ as possible options in the AutoAction field. You might try the AUTOPRT one. I’m still digging.

1 Like

I created a report style and i did a routing to print in an specific printer and set it in my code as print preview and it works

1 Like