Thanks for the reply, Jeff. Looking at that table, I’m not sure what the flag would be to trigger a BPM. Below is what I have now, base on the details in my first post.
There’s a Pre-Processing setup like this:
And a Post Processing setup like this:
The code in the Custom Code is:
string vapprov = string.Empty;
string vbuyer = string.Empty;
Erp.Tables.PurAgent PurAgent;
foreach (var ttPOHeader_iterator in (from ttPOHeader_Row in ttPOHeader where string.Compare(ttPOHeader_Row.ApprovalStatus ,“P” ,true)==0
select ttPOHeader_Row))
{
var ttPOHeaderRow = ttPOHeader_iterator;
if (ttPOHeader_xRow != null)
{
PurAgent = (from PurAgent_Row in Db.PurAgent
where PurAgent_Row.Company == ttPOHeaderRow.Company && PurAgent_Row.BuyerID
== ttPOHeaderRow.BuyerID
select PurAgent_Row).FirstOrDefault();
vapprov = PurAgent.ApprovalPerson;
PurAgent = (from PurAgent_Row in Db.PurAgent
where PurAgent_Row.Company == ttPOHeaderRow.Company && PurAgent_Row.BuyerID
== vapprov
select PurAgent_Row).FirstOrDefault();
vapprov = PurAgent.EMailAddress;
PurAgent = (from PurAgent_Row in Db.PurAgent
where PurAgent_Row.Company == ttPOHeaderRow.Company && PurAgent_Row.BuyerID
== ttPOHeaderRow.BuyerID
select PurAgent_Row).FirstOrDefault();
vbuyer = PurAgent.EmailAddress;
if (!String.IsNullOrEmpty(vapprov))
{
string vFrom = string.Empty;
string vTo = string.Empty;
string vCC = string.Empty;
string vSubject = string.Empty;
string vBody = string.Empty;
Services.Bpm.BpmEmail hEmailEx = null;
hEmailEx = new Services.Bpm.BpmEmail();
vFrom = vbuyer;
vTo = vapprov;
vCC = "";
vSubject = vSubject + "Purchase Order " + System.Convert.ToString(ttPOHeaderRow.PONUM) + " needs " + "approval";
vBody = vBody + "The above purchase order number requires approval";
hEmailEx.SendEmail(false, Session.CompanyID, vFrom, vTo, vCC, vSubject, vBody, "");
if (hEmailEx != null)
{
hEmailEx.Dispose();
}
break;
}
}
}
And here is the error that I get when trying to save the BPM:
Server Side Exception
There is at least one compilation error.
Exception caught in: Epicor.ServiceModel
Error Detail
Description: There is at least one compilation error.
Details:
Error CS0103: The name ‘ttPOHeader_xRow’ does not exist in the current context [Update.Post.EmailApproverOnL.cs(102,9)]
Error CS1061: ‘Erp.Tables.PurAgent’ does not contain a definition for ‘EmailAddress’ and no extension method ‘EmailAddress’ accepting a first argument of type ‘Erp.Tables.PurAgent’ could be found (are you missing a using directive or an assembly reference?) [Update.Post.EmailApproverOnL.cs(120,27)]
Error CS0246: The type or namespace name ‘Services’ could not be found (are you missing a using directive or an assembly reference?) [Update.Post.EmailApproverOnL.cs(129,13)]
Error CS0246: The type or namespace name ‘Services’ could not be found (are you missing a using directive or an assembly reference?) [Update.Post.EmailApproverOnL.cs(130,28)]
Error CS1061: ‘Erp.Tablesets.POHeaderRow’ does not contain a definition for ‘PONUM’ and no extension method ‘PONUM’ accepting a first argument of type ‘Erp.Tablesets.POHeaderRow’ could be found (are you missing a using directive or an assembly reference?) [Update.Post.EmailApproverOnL.cs(134,93)]
Program: Epicor.Customization.dll
Method: PrepareException
Line Number: 99
Column Number: 13
Server Trace Stack: at Epicor.Customization.Standard.CustomizationCompiler.PrepareException(CompilerErrorCollection errors) in c:_Releases\ICE\3.1.400.19\source\Framework\Epicor.Customization\Standard\CustomizationCompiler.cs:line 99
at Epicor.Customization.Standard.CustomizationCompiler.Compile(BuildEnvironment input, String outputAssembly) in c:_Releases\ICE\3.1.400.19\source\Framework\Epicor.Customization\Standard\CustomizationCompiler.cs:line 62
at Epicor.Customization.Standard.CustomizationBuilder.Process(CustomizationProject project) in c:_Releases\ICE\3.1.400.19\source\Framework\Epicor.Customization\Standard\CustomizationBuilder.cs:line 78
at Ice.Services.BO.BpMethodSvc.AfterUpdate() in c:_Releases\ICE\3.1.400.19\source\Server\Services\BO\BpMethod\BpMethod.Events.cs:line 89
at Ice.Services.Trace.TablesetProfilingCollector.DoTablesetEventTrace(String tablesetName, String methodName, Action action) in c:_Releases\ICE\3.1.400.19\source\Framework\Epicor.Ice\Services\TablesetProfilingCollector.cs:line 198
at Ice.TablesetBound3.InnerUpdate(IceDataContext dataContext, TFullTableset tableset) in c:\_Releases\ICE\3.1.400.19\source\Framework\Epicor.Ice\Services\TablesetBound.cs:line 813 at Ice.Services.BO.BpMethodSvc.Update(BpMethodTableset& ds) in c:\_Releases\ICE\3.1.400.19\source\Server\Services\BO\BpMethod\BpMethod.Designer.cs:line 837 at Ice.Services.BO.BpMethodSvcFacade.Update(BpMethodTableset& ds) in c:\_Releases\ICE\3.1.400.19\source\Server\Services\BO\BpMethod\BpMethodSvcFacade.cs:line 224 at SyncInvokeUpdate(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Epicor.Hosting.OperationBoundInvoker.InnerInvoke(Object instance, Func
2 func) in c:_Releases\ICE\3.1.400.19\source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 59
at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func2 func) in c:\_Releases\ICE\3.1.400.19\source\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 28 at Epicor.Hosting.Wcf.EpiOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) in c:\_Releases\ICE\3.1.400.19\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.ProcessMessage31(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.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.Security.NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ReadCallback(AsyncProtocolRequest asyncRequest)
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.ServiceModel.Channels.SocketConnection.OnReceiveAsync(Object sender, SocketAsyncEventArgs eventArgs)
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 Ice.Proxy.BO.BpMethodImpl.Update(BpMethodDataSet ds)
at Ice.Adapters.BpMethodAdapter.OnUpdate()
at Ice.Lib.Framework.EpiBaseAdapter.Update()
at Ice.UI.App.BpMethodEntry.Transactions.MainTransactionBase.adapterUpdate()