@Chris_Conn, I think @aidacra is going to make me beg.
Further investigate I’ve also discovered that this BPM also triggers the email send three times per BPM trigger, no matter how many lines on the SO or anything else I can find. It’s always three emails.
Now ironically, the “BPM Test email” node only emails once per BPM trigger. There is no loop in the C# code as I stripped the C# to the bare; Setting the variables in Set Argument/Variable nodes no IF or While statements in the code at all (code below screen shot)
Any ideas what I’m missing?
// Send SSRS Email Order Acknowledge in PDF Format
var soForm = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderAckSvcContract>(Db);
SalesOrderAckTableset soTS = soForm.GetNewParameters();
SalesOrderAckParamRow r = soTS.SalesOrderAckParam[0];
r.OrderNum = OrderNum; // OrderNum var
r.SysRowID = Guid.Parse("00000000-0000-0000-0000-000000000000");
r.AutoAction = "SSRSPrint";
r.AgentSchedNum = 0;
r.AgentID = "SystemTaskAgent";
r.AgentTaskNum = 0;
r.RecurringTask = false;
r.RptPageSettings = "";
r.RptPrinterSettings = "";
r.RptVersion = "";
r.ReportStyleNum = 2; // 1002 = Our Report Style 2 = Default SSRS
r.WorkstationID = "";
r.TaskNote = "OdrAck Email";
r.ArchiveCode = 0;
r.DateFormat = "m/d/yyyy";
r.NumericFormat = ",.";
r.AgentCompareString = "";
r.ProcessID = "";
r.ProcessTaskNum = 0;
r.DecimalsGeneral = 0;
r.DecimalsCost = 0;
r.DecimalsPrice = 0;
r.GlbDecimalsGeneral = 0;
r.GlbDecimalsCost = 0;
r.GlbDecimalsPrice = 0;
r.FaxSubject = string.Format("Order Confirmation for PO#: {0}.", PONum);
r.FaxTo = "";
r.FaxNumber = "";
r.EMailTo = CustEmail;
r.EMailCC = "";
r.EMailBody = "Thank you for your order. \n\r Attached please find the order acknowledgement for PO#: " + PONum + " Southern Imperial sales order #: " + OrderNum + ". Please review for accuracy. \n\r Inquiries on this order may be addressed to " + CSR_Name + " at 1-800-747-4665 or email: " + CSR_Email; // Email Body
r.EMailBCC = "";
r.AttachmentType = "PDF";
r.ReportCurrencyCode = "USD";
r.ReportCultureCode = "en-US";
r.SSRSRenderFormat = "PDF";
r.RowMod = "A";
soForm.RunDirect(soTS);
I’m not sure why it would be three times, but I found that saving a line on a sales order will trigger the data directive with two OrderHed records, one that has RowMod=“” and second with “U”. For checking this sort of thing I like to add a custom code at the start of the directive something like the following:
int RecordCnt = 0;
foreach (var MyOrderHed in (from OrderHedRecord in ttOrderHed /*where
RcvDtlRecord.RowMod == IceRow.ROWSTATE_ADDED */
select OrderHedRecord ))
{
this.PublishInfoMessage(" “+RecordCnt+” RowMod: “+MyOrderHed.RowMod+” OrderNum: “+MyOrderHed.OrderNum
, Ice.Common.BusinessObjectMessageType.Information
, Ice.Bpm.InfoMessageDisplayMode.Individual,”&q uot;“,”");
RecordCnt++;
}
Thanks @AndrewM, I’ll try that. Last night I moved the trigger logic to an In Transaction BPM but I’ll add this too.
@Randy @AndrewM @aidacra @Chris_Conn
I use the exact same method to print the order acknowledgement:
But for one specific user we get this message and it will not work… Any ideas? I will put the stack trace below with the error message.
Business Layer Exception
Program Ice.Services.Lib.RunTask raised an unexpected exception with the following message: RunTask: Object reference not set to an instance of an object.
Stack Trace:
at Ice.Core.SsrsReporting.PdfReportPrinter.Print(Byte[] reportBytes, String printerNameParameter, String reportDescription, EpiPrinterSettings printerSettings, EpiPageSettings pageSettings) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\PdfReportPrinter.cs:line 32
at Ice.Core.SsrsReporting.ReportProcessorBase`1.RenderReportForPrintFaxOrEmailReport(RenderedSsrsReport renderedReport, Boolean serverSidePrint, Boolean ignorePageSettings) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\ReportProcessorBase.cs:line 398
at Ice.Core.SsrsReporting.ReportProcessorBase`1.ProcessReportPart(String reportLocation) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\ReportProcessorBase.cs:line 169
at Ice.Core.SsrsReporting.StandardReportProcessor`1.ProcessReportParts() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\StandardReportProcessor.cs:line 33
at Ice.Core.RptBase.ReportSsrsDatabaseBuilder`1.<>c__DisplayClass10_0.<ProcessUnroutedReport>b__0(ReportInstanceInformation instance) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportSsrsDatabaseBuilder.cs:line 231
at Ice.Core.RoutingAndBreaking.ReportPersister.Persist(ReportInstanceInformation reportInstance, Func`2 reportsRenderer, Action`1 fillSysRptLstRow, Action`2 processReport) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RoutingAndBreaking\ReportPersister.cs:line 44
at Ice.Core.RptBase.ReportSsrsDatabaseBuilder`1.ProcessUnroutedReport() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportSsrsDatabaseBuilder.cs:line 233
at Ice.Core.RptBase.ReportDatabaseBuilder`1.XMLClose() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportDatabaseBuilder.cs:line 142
at Ice.Core.RptTaskBase`1.XMLClose() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\RptTaskBase.cs:line 130
at Ice.Hosting.TaskCaller.InnerExecuteTask(IceDataContext newContext) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 93
at Ice.Hosting.TaskCaller.ExecuteTask(IceDataContext dataContext, Boolean suppressTransaction) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 40
at Ice.Lib.RunTask.BpmFriendlyTaskLauncher.Run(String sessionIdPrefix, IceContext db, Action taskRunner) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\BpmFriendlyTaskLauncher.cs:line 63
at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\RunTask.cs:line 526
Exception caught in: Epicor.ServiceModel
Error Detail
============
Description: Program Ice.Services.Lib.RunTask raised an unexpected exception with the following message: RunTask: Object reference not set to an instance of an object.
Stack Trace:
at Ice.Core.SsrsReporting.PdfReportPrinter.Print(Byte[] reportBytes, String printerNameParameter, String reportDescription, EpiPrinterSettings printerSettings, EpiPageSettings pageSettings) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\PdfReportPrinter.cs:line 32
at Ice.Core.SsrsReporting.ReportProcessorBase`1.RenderReportForPrintFaxOrEmailReport(RenderedSsrsReport renderedReport, Boolean serverSidePrint, Boolean ignorePageSettings) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\ReportProcessorBase.cs:line 398
at Ice.Core.SsrsReporting.ReportProcessorBase`1.ProcessReportPart(String reportLocation) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\ReportProcessorBase.cs:line 169
at Ice.Core.SsrsReporting.StandardReportProcessor`1.ProcessReportParts() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\SsrsReporting\StandardReportProcessor.cs:line 33
at Ice.Core.RptBase.ReportSsrsDatabaseBuilder`1.<>c__DisplayClass10_0.<ProcessUnroutedReport>b__0(ReportInstanceInformation instance) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportSsrsDatabaseBuilder.cs:line 231
at Ice.Core.RoutingAndBreaking.ReportPersister.Persist(ReportInstanceInformation reportInstance, Func`2 reportsRenderer, Action`1 fillSysRptLstRow, Action`2 processReport) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RoutingAndBreaking\ReportPersister.cs:line 44
at Ice.Core.RptBase.ReportSsrsDatabaseBuilder`1.ProcessUnroutedReport() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportSsrsDatabaseBuilder.cs:line 233
at Ice.Core.RptBase.ReportDatabaseBuilder`1.XMLClose() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\ReportDatabaseBuilder.cs:line 142
at Ice.Core.RptTaskBase`1.XMLClose() in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\RptBase\RptTaskBase.cs:line 130
at Ice.Hosting.TaskCaller.InnerExecuteTask(IceDataContext newContext) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 93
at Ice.Hosting.TaskCaller.ExecuteTask(IceDataContext dataContext, Boolean suppressTransaction) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 40
at Ice.Lib.RunTask.BpmFriendlyTaskLauncher.Run(String sessionIdPrefix, IceContext db, Action taskRunner) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\BpmFriendlyTaskLauncher.cs:line 63
at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\RunTask.cs:line 526
Program: Ice.Services.Lib.RunTask.dll
Method: InnerRunTask
Line Number: 526
Column Number: 25
Server Trace Stack: at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\RunTask.cs:line 526
at Ice.Services.Lib.RunTaskSvcFacade.RunTaskDirect(Int64 ipTaskNum) in D:\_Releases\ICE\3.1.500.31\Source\Server\Services\Lib\RunTask\RunTaskSvcFacade.cs:line 103
at Ice.Core.TaskServiceBase`1.InnerRunDirect(IceRow paramRow) in D:\_Releases\ICE\3.1.500.31\Source\Server\Internal\Lib\TaskLib\TaskBase\TaskServiceBase.cs:line 587
at Erp.Services.Rpt.SalesOrderAckSvc.RunDirect(SalesOrderAckTableset ds) in c:\_Releases\ERP\RL10.1.500\Source\Server\Services\Rpt\SalesOrderAck\SalesOrderAck.Designer.cs:line 199
at Erp.Services.Rpt.SalesOrderAckSvcFacade.RunDirect(SalesOrderAckTableset ds) in c:\_Releases\ERP\RL10.1.500\Source\Server\Services\Rpt\SalesOrderAck\SalesOrderAckSvcFacade.cs:line 211
at Epicor.Customization.Bpm.DB017FE532455048AFA2690B2FAE48155A.PostTranDirective_AutoOrderAckV2_1BCC788C0ED942E9B5A2FEBD93DBA84A.A001_CustomCodeAction()
at Epicor.Customization.Bpm.DB017FE532455048AFA2690B2FAE48155A.PostTranDirective_AutoOrderAckV2_1BCC788C0ED942E9B5A2FEBD93DBA84A.ExecuteCore()
at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in c:\_Releases\ICE\3.1.500\Current\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 160
at System.Linq.Enumerable.All[TSource](IEnumerable`1 source, Func`2 predicate)
at Epicor.Customization.Bpm.CustomizationBase2`3.Execute(TParam parameters) in c:\_Releases\ICE\3.1.500\Current\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.cs:line 77
at Epicor.Customization.Bpm.Standard.MonitoringSessionManager.ProcessCollectedData(IceContext db, IRowChangesCollection data, IDirectiveEnabler enabler) in c:\_Releases\ICE\3.1.500\Current\Source\Server\Internal\Lib\Epicor.Customization.Bpm\Standard\MonitoringSessionManager.cs:line 138
at Epicor.Customization.Bpm.SvcFacadeBase`3.Epicor.Hosting.IBpmReadyService.FinalizeCall(Object state, Boolean fail) in c:\_Releases\ICE\3.1.500\Current\Source\Server\Internal\Lib\Epicor.Customization.Bpm\SvcFacadeBase.Generic.cs:line 214
at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func`2 func) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 32
at Epicor.Hosting.Wcf.EpiOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) in D:\_Releases\ICE\3.1.500.31\Source\Framework\Epicor.System\Hosting\Wcf\EpiOperationInvoker.cs:line 23
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SecurityChannelListener`1.ReceiveItemAndVerifySecurityAsyncResult`2.InnerTryReceiveCompletedCallback(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Security.NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ReadCallback(AsyncProtocolRequest asyncRequest)
at System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result)
at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(Object state)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Client Stack Trace
==================
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Erp.Proxy.BO.SalesOrderImpl.MasterUpdate(Boolean lCheckForOrderChangedMsg, Boolean lcheckForResponse, String cTableName, Int32 iCustNum, Int32 iOrderNum, Boolean lweLicensed, Boolean& lContinue, String& cResponseMsg, String& cCreditShipAction, String& cDisplayMsg, String& cCompliantMsg, String& cResponseMsgOrdRel, SalesOrderDataSet ds)
at Erp.Adapters.SalesOrderAdapter.MasterUpdate(Boolean lCheckForOrderChangedMsg, Boolean lcheckForResponse, String cTableName, Int32 iCustNum, Int32 iOrderNum, Boolean lweLicensed, Boolean& lContinue, String& cResponseMsg, String& cCreditShipAction, String& cDisplayMsg, String& cCompliantMsg, String& cResponseMsgOrdRel)
at Erp.UI.App.SalesOrderEntry.Transaction.Update()
It is actually working for everyone else and you are a wonderful man for creating that original post and getting all those good tips. It is just this ONE user that gets a message and what I am wondering is if she can’t get the referenced .dll or something of the sort. I just don’t understand how one user can’t check the box and trigger this data directive. She always gets the error I posted. Any other user can do it.
That user doesn’t have access\permission to use the selected printer or report?
I start by testing it manually with the same settings and see what the result is.
I don’t know what printer that would be because it is emailed from this data directive. She is able to print the report manually. In the system monitor I see that the system agent is the initiator when she prints it manually, but when the data directive runs it is initiated by the client.
I’ve noticed E10 SSRS is more picky on users Default Printers in Windows.
Especially when Win10 sets the default to the XPS printer. Can they print
the form manually from the menu or do they get an error?
Kinda lends credence to a permissions issue on some resource then. Maybe someone else here has a clue.
Could it be that the CSR email isnt set for her?
@Randy @Nathan_Woolen @Chris_Conn She can print it manually without any issues.
I will check her default printer, but I believe it would be the printer nearest to her desk which is what others have as their default printer and they are not having any issues.
@Chris_Conn I spent a lot of time yesterday trying to figure out if it was a permissions issue, but I gave her all the permissions in the world in Epicor and it didn’t do a thing. I also have printed the order using this customization and it works just fine.
@Randy @aidacra @Nathan_Woolen @Chris_Conn
I think it is either failing to create the correct “object” at this point:
var soForm = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderAckSvcContract>(Db);
SalesOrderAckTableset soTS = soForm.GetNewParameters();
SalesOrderAckParamRow r = soTS.SalesOrderAckParam[0];
OR
at the very end:
soForm.RunDirect(soTS);
Something is not getting set.
Any ideas?
It might be useful to make a BAQ on SysTask and filter her records so you can have look if there are any clues there. Probably the best thing to do is check the box DEBUG IN VISUAL STUDIO on your customization. Then you can put a breakpoint there and actually view the object before it’s passed (and after for that matter)
If you don’t own VS, you can get the community edition for free.
@Chris_Conn I am not sure how to debug in VS. We have tried to do it a few times, but we haven’t had much success. The most we’ve been able to do is correctly reference all the assemblies for a certain BO and then write some code and verify that its syntax is correct.
We have never imported a session to an Epicor environment or done debugging on live events. Do you have any documentation or guides that you use to set this up?
No setup required
Make sure you have a recent copy of VS installed.
Activate customization mode with wrench icon in E10
Click screen menu you want - selection screen opens
Check DEBUG in VS and select the desired customization
Click OK
VS will automatically open in needed (DO NOT CLOSE VS UNTIL YOU ARE DONE DOING ANY E10 DEBUGGING - if you do, you will also have to restart E10 to debug again)
VS opens up to a breakpoint at the startup of your customization (like at the top of your script)
Put a breakpoint on soForm.RunDirect(soTS);
You can put your cursor on the line and press F9 - you’ll get a red circle to the left, this is the breakpoint icon
Note that F9 toggles, so if you press it again, your breakpoint goes away
Once BP is set - click the green run icon (or F5) - Your form will load up and display. Do whatever triggers your bit of code and the breakpoint will be triggered.
Now you can hover over the soTS object to view its state (or add it watch window).
If it’s null, that’s an issue but also drill down into the object to look at the fields you think you’ve set.
Blockquote
I would like to add that debugging like this on the client affects only the client. You wont cause any issues with other users or the system (unless you really try - and if you do, call me if you want some help to do that haha) - the reason I point this out is because when you start debugging on the server side that’s a horse of different color. Breakpoints on the server - break EVERYONE haha