I’m using the below code to print some invoices.
It works, for the most part, but I’m running into 2 snags.
-
I have to be logged in as the user that scheduled the task (it runs using User Process Scheduler), which is annoying.
-
I’m trying to have it go to APM, but it never makes it. When I look at the client it brings up the save window for a *.XPS file. What have I missed?
using(var arForm = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ARInvFormSvcContract>(Db)) { ARInvFormTableset arTS = arForm.GetNewParameters(); ARInvFormParamRow r = arTS.ARInvFormParam[0]; r.InvoiceNum = Convert.ToInt32(result.ih.InvoiceNum); r.CurGroup = ""; r.PrintNPost = false; r.Vouchering = false; r.AssignLegalNumber = false; r.Description = ""; r.DocTypeOption = "All"; r.EnableAssignLegalNumber = false; r.PrintStatusOption = "All"; r.TranDocTypeID = ""; r.TransOptions = "ARC"; r.CustList = ""; r.DCList = ""; r.TH_IsService = false; r.ARInvFormReportID = ""; r.BeginNum = ""; r.EndNum = ""; r.InvoiceStatusOption = "A"; r.THHeadOfficeOrBranch = ""; r.THPlaceOfBusiness = ""; r.TWCompInvPart1 = true; r.TWCompInvPart2 = false; r.TWCompInvPart3Front = false; r.TWCompInvPart3Back = false; r.SysRowID = Guid.Empty; r.AutoAction = "PRINT"; r.PrinterName = "Epicor APM Printer"; r.AgentSchedNum = 0; r.AgentID = "SystemTaskAgent"; r.AgentTaskNum = 0; r.RecurringTask = false; r.RptPageSettings = ""; r.RptPrinterSettings = ""; r.RptVersion = ""; r.ReportStyleNum = 1015; r.WorkstationID = "ISIEPICOR 2"; r.TaskNote = ""; r.ArchiveCode = 1; //7 for a week r.DateFormat = @"m/d/yyyy"; r.NumericFormat = ",."; r.AgentCompareString = ""; r.ProcessID = ""; r.ProcessCompany = ""; r.ProcessSystemCode = ""; r.ProcessTaskNum = 0; r.DecimalsGeneral = 0; r.DecimalsCost = 0; r.DecimalsPrice = 0; r.GlbDecimalsGeneral = 0; r.GlbDecimalsCost = 0; r.GlbDecimalsPrice = 0; r.FaxSubject = ""; r.FaxTo = ""; r.FaxNumber = ""; r.EMailTo = ""; r.EMailCC = ""; r.EMailBCC = ""; r.EMailBody = ""; r.AttachmentType = ""; r.ReportCurrencyCode = result.ih.CurrencyCode.ToString(); r.ReportCultureCode = "en-US"; r.UIXml = ""; r.PrintReportParameters = false; r.SSRSEnableRouting = false; r.SSRSRenderFormat = "PDF"; r.RowMod = "A"; arForm.RunDirect(arTS); }//End using