BPM on Payment Entry

I am trying both Method and Data directives on PaymentEntry or CheckHed to populate a custom field on checkhed with a calculate based around DocCheckAmt * ExchangeRate. I have tried both widgets and C# and i cannot get it to populate.

This is my latest effort (Or lack of :rofl:)


C# i last did when i was in college so please dont laugh

Pre or post processing method directive?

Post

That’s your problem. Change it to pre, or you have to call update again.
In post, the update has already happened, further changes to the fields will not update unless you handle it’s processing.

Do you think the code should work if i move it to Pre?

It should, as long as the DocCheckAmt and ExchangeRate is populated with the correct value before update.

You could also use an in-transaction data directive.

Got it working in an In-transaction data directive using



OK so i thought the above worked and it does to pull in the details to the field but when Finance go to process the payments, they are getting the following error -

Program Ice.Services.Lib.RunTask when executing task 22636 raised an unexpected exception with the following message: RunTask: Ice.Common.EpicorServerException: BPM runtime caught an unexpected exception of ‘MissingMethodException’ type. See more info in the Inner Exception section of Exception Details. —> System.MissingMethodException: Method not found: ‘Void Erp.Tables.CheckHed.set_PaymentTotalGBP_c(System.Decimal)’. at Epicor.Customization.Bpm.DB.InTranDirective_CalculateGBPTotal_51FF858792234A7B97983CB013C79EFD.A001_SetFieldAction() at Epicor.Customization.Bpm.DB.InTranDirective_CalculateGBPTotal_51FF858792234A7B97983CB013C79EFD.ExecuteCore(Int32 step) at Epicor.Customization.Bpm.DirectiveBase`2.Execute() in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 341 at Epicor.Customization.Bpm.DirectiveBase`2.Execute(TParam parameters) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 195 — End of inner exception stack trace — at Epicor.Customization.Bpm.DirectiveBase`2.Execute(TParam parameters) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 211 at Epicor.Customization.Bpm.TriggerBase`2.RunDirectives(TriggerParameters`1 parameters) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\TriggerBase.cs:line 51 at Epicor.Customization.Bpm.CustomizationBase2`2.Execute(TParam parameters) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\CustomizationBase2.cs:line 99 at Epicor.Customization.Bpm.InTranTriggerBase2`2.Write(LinqRow newRecord, LinqRow oldRecord) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Customization\Epicor.Customization.Bpm\InTranTriggerBase2.cs:line 103 at Ice.Triggers.TriggerQueue.ExecuteBpmWriteTrigger(IceDataContext context, LinqRow modifiedRecord, LinqRow originalRec) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 349 at Ice.Triggers.TriggerQueue.RunWriteTriggerInNewLevel(IceDataContext context, LinqRow modifiedRecord, LinqRow originalRecord, Boolean forAddedRow) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 172 at Ice.Triggers.TriggerQueue.RunAtNewLevel(Func`1 buildTriggerRunState, Action action) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 498 at Ice.Triggers.TriggerQueue.RunTriggers(IceDataContext context) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Triggers\TriggerQueue.cs:line 56 at Ice.IceDataContext.RunUntilAllTriggersHaveExecuted() in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Data\EntityFramework\EF6\IceDataContext.cs:line 835 at Ice.IceDataContext.SaveChanges() in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.System\Data\EntityFramework\EF6\IceDataContext.cs:line 889 at Erp.Internal.AP.ProcessPayment.processChecks(FormatNumberToCheckAmountCache checkAmountFormatterCache) in C:\_releases\ERP\ERP12.1.100.6\Source\Server\Internal\AP\ProcessPayment\ProcessPayment.cs:line 2508 at Erp.Internal.AP.ProcessPayment.RunProcess(Int64 instanceTaskNum, String outputFileName) in C:\_releases\ERP\ERP12.1.100.6\Source\Server\Internal\AP\ProcessPayment\ProcessPayment.cs:line 724 at Ice.Hosting.TaskCaller.InnerExecuteTask(IceDataContext newContext) in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 71 at Ice.Hosting.TaskCaller.ExecuteTask() in C:\_releases\ICE\ICE5.1.100.6\Source\Server\Framework\Epicor.Ice\Hosting\TaskCaller\TaskCaller.cs:line 62 at Ice.Lib.RunTask.BpmFriendlyTaskLauncher.Run(String sessionIdPrefix, IceContext db, Action taskRunner) in C:\_releases\ICE\ICE5.1.100.0\Source\Server\Services\Lib\RunTask\BpmFriendlyTaskLauncher.cs:line 57 at Ice.Services.Lib.RunTaskSvc.InnerRunTask(Int64 ipTaskNum, Boolean suppressTransaction) in C:\_releases\ICE\ICE5.1.100.0\Source\Server\Services\Lib\RunTask\RunTask.cs:line 349

Further to this i may be making this too complicated (Although not sure the BPM itself is complex) but there is a field on the CheckHed table called CheckAmt which is the amount in the Base currency which is actually what i am after. I can expose this field on the Payment Details screen BUT it is not available as a field on the Current Payments in Process view on the AP Payment Entry screen.

Are you on prem or hosted? Idk how hosted UD fields work, but if you’re on prem, make sure you’ve regenerated the data model and recycled IIS.

CheckHed.Update probably gets called in a bunch of different places. Put conditions on your BPM so it only sets the UD field when you want it to.

I would try to get this into a method directive. Besides Update, what other methods show up in your trace for whatever you’re doing?

I am on Prem. Update was the only one i could seem i did try a method directive but could not get that to pull the data through hence going down the data directive route

I believe the issue us because we have two App Servers. I did a Regen and recycle on one (The normal one when i have done BPMs before) but as this involves a process i need to do the same on the other as well. Unfortunately i have the Sever Version mismatch error on the second server so need to wait for that to be sorted.

Anyone got any ideas on this one? If i dont need the BPM then it would be better to use an existing field but i cant seem to expose it in the Current Payments in Process view. :thinking:

Both app servers need to have the same data model. It looks like your one appserver is accepting the request, but does not have the updated data model.

Yeah we just did a regen on the second server that does the processes (Took a while as had a version mismatch error and had to remove and restore the database on that server). Have redeployed the BPM so hopefully it will now run when they do the payment run tomorrow.

Any idea why the CheckHed.CheckAmt field would not appear in the Current Payments view and how best to get it in there as it seems to appear in the LandingPage dataview which it looks like what the view is bound to.

If the business object does not return it, you will have to add a field to it as explained here:

https://www.epiusers.help/t/adding-columns-to-existing-grid-in-kinetic