Automating Fulfillment Workbench Via Epicor Function

Functions give you a limited data model. You start off with nothing and need to opt in tables using the reference tab. However this gives a different type of Db context that cannot be automatically converted to an ErpContext.

You can create an ErpContext in a function code block with the below code and pass it. Fair warning, I have not tested that this actually processes the deferred transaction. I know it creates a Db context of the correct type and it compiles:

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

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

I was using this call in an SDK generated object which has a native ErpContext which is why I did not bump into this issue.

4 Likes