Function to create CustShip works from Schedule Epicor Function, but not from REST/Swagger. Are Update & MasterUpdate broken?

Thank you for the reply, much appreciated! You are spot on, it creates records in PartBinDeferred and PartQtyDeferred. But it processes them after around 20-30 minutes, anything I can do to speed that up? Or I shouldn’t mess with it?

Dont mess with it, let Epicor be Epicor :slight_smile: There are ways in which you can speed it up, but its not worth it.

Here’s how just because but again not something you should worry about

1 Like

I played around with that a little but it doesn’t seem to work for me. Maybe because it is called from a function. But even if I make it work, I don’t want to think what will happen if it fails.
Anyway, I know what’s going on and it makes total sense. I think I am going to split this function in 2: first will dump the data into an UD table and the second will pick that up and create the pack. Maybe schedule the second one every 5 or 10 mins. Thanks a lot again!

Oh no, why not? I just implemented this code you referenced (though not in Production yet) for an inventory transfer app I’m working on.

Sorry if the cons have been addressed, but I don’t recall seeing it (just skimmed that thread again, too).

I mean it just speeds up something that Epicor is doing anyway, there is no real upside and the software already accounts for these. Is just more code to write and maintain.

@josecgomez So the reason I “needed” it was that, in testing the EFx in Postman, I wasn’t able to transfer the same part number twice in a row - even minutes apart. In all seriousness, what other way is there around that?

@Dragos I used Carson’s modified code here:

If you have that in a function, would you mind sharing the code? I tried both below but doesn’t seem to do the trick for me:

Epicor.Functions.IFunctionHost host = (Epicor.Functions.IFunctionHost)this.GetType().BaseType.BaseType.GetField("host", System.Reflection.BindingFlags.NonPublic |  System.Reflection.BindingFlags.Instance).GetValue(this);
var Dbl = (Erp.ErpContext)host.GetIceContext();
Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(Dbl);
libDeferredUpdate.UpdPQDemand();

/*
var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();
Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(context);
libDeferredUpdate.UpdPQDemand();
*/

Oh it’s quite literally Carson’s version, but I pasted it at the end of this post for reference. Looks like what you have commented out.

I put that in a custom code widget at the very end and I do everything else in no-code widgets.

Plus I needed the assembly of Erp.Internal.Lib.DeferredUpdate

var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();

Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(context);
libDeferredUpdate.UpdPQDemand();

image

In Later versions you have to add some context for it to worknight, also in Functions 700+ you should be able to use a Context Creator to get around that Reflection stuff
Try this if the above doesn’t work

var Dbcontext = Ice.Services.ContextFactory.CreateContext();
 
Erp.Internal.Lib.ErpCallContext.Add(“PBOnHand-Post”,””); // PartBin
Erp.Internal.Lib.ErpCallContext.Add(“PQDemand-Post”,””); // Part Quantity
Erp.Internal.Lib.ErpCallContext.Add(“PLOnHand-Post”,””); // Part Lot
 
Erp.Internal.Lib.DeferredUpdate libDeferredUpdate = new Erp.Internal.Lib.DeferredUpdate(Dbcontext);
libDeferredUpdate.UpdPQDemand();
 
Erp.Internal.Lib.ErpCallContext.RemoveValue(“PBOnHand-Post”);
Erp.Internal.Lib.ErpCallContext.RemoveValue(“PQDemand-Post”);
Erp.Internal.Lib.ErpCallContext.RemoveValue(“PLOnHand-Post”);
1 Like

Thanks @josecgomez! What reference do I need for Erp.Internal.Lib.ErpCallContext ? I cannot seem to find it. I already have Erp.Internal.Lib.DeferredUpdate

I learn something new every day here… Thanks Jose.

Do widget based BO calls create a context?

Erp.Internal.Lib.Shared.dll

1 Like

The widget stuff works out of the box. So yes ish kinda.

2 Likes

Thanks

Hmmm… I’m getting this on the server side:

<![CDATA[System.Data.Entity.Core.EntityException: The underlying provider failed on Open. —> System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool. —> System.Runtime.InteropServices.COMException: The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)
at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte propagationToken)

Widgets Code
1 542

Hey, I’ll take it as a win.

HAAHAHA that’s funny Jason. I think you are the only one playing the game and keeping score at the moment. Both ways are great. I really wish I knew how to code using BO calls like the people on here. I will get it soon enough, I just haven’t worked up the will to dive in and learn right now.

1 Like

however you can’t invoke the Deffered Stuff from a widget I don’t think.

1 Like

Do you hve the require transaction checkbox on your function checked?