Closing orders through BPM

I have an InTransaction Data Directive, that I want to close an order.

The DD monitors the OrderHed table, for changes to a custom field OrderHed.BillingComplete_c (a boolean)

I then made an Updatable BAQ where users can check off that BillingComplete check box.

I had the DD use a Set Field block to set the OrderHed.OpenOrder to FALSE. But that only sets that field, and doesn’t do the same as the “Close Order” Action in the order entry screen(which also closes the lines and releases).

How can I execute the “Close Order” functionality from within an In-Tran DD?

I could use the Set By Query block to find the open lines and releases related to that order, and close them. But I feel that the “Close Order” function may do much more.

1 Like

I believe there is a close order method that needs to be called. If you were using a method directive you could use Invoke BO Method and call it without any code. In a data directive you’re going to need to use Usings & References to import dlls so you can call that method. Is it possible to use a method directive?

1 Like

The Updatable BAQ does call DynamicQuery.Update.

I guess I would just need to have that BPM be able to identify the uBAQ and the context in which it was called.

I’m trying to do essentially the same thing.

I’m trying to execute the CloseRelease method on SalesOrder from within custom code in a Data Directive BPM.

In the BPM custom code I’m trying to create the following object:
var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrder>(Db);

I’ve added the reference to the Erp.Contracts.BO.SalesOrder Assembly but when I try to save I get:

Description: There is at least one compilation error.
Details:
Error CS0234: The type or namespace name ‘SalesOrder’ does not exist in the namespace ‘Erp.Contracts’ (are you missing an assembly reference?) [InTran.Auto_Close_Relea.cs(90,79)]
Program: Epicor.Customization.dll

Anyone have any ideas on how to properly resolve the dependency?

You can use something like this.

> orderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);

2 Likes

Thanks, that worked and I was able to get it to compile and I’ve added enough debug statements to know that the code is being executed but my Release is not getting closed.

Could you paste the code you are using? Does it look something like this?

> int iOrder = 5370, iOrderLine = 1, iOrderRelease = 1;
> using (Erp.Contracts.SalesOrderSvcContract soSvc =  Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
> {
> soSvc.CloseRelease(iOrder,iOrderLine,iOrderRelease);
> }

My code was close but I’ve tried your exact code (changing order number obviously) and unfortunately it still doesn’t close the release.

Are there any messages in the server log when you attempt to run this?

I cannot see anything related to the CloseRelease method in the server log

Could you post your code and what directive you are using?

It’s an In Transaction Data Directive on OrderRel.

Here’s the code:

var ttOrderRel_xRow = (from ttOrderRel_Row in ttOrderRel
    select ttOrderRel_Row).FirstOrDefault();

if (ttOrderRel_xRow != null)
{

    this.PublishInfoMessage("Test: OrderRel updated", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "CustShip", "Update");

    if (ttOrderRel_xRow.SellingReqQty - ttOrderRel_xRow.SellingJobShippedQty - ttOrderRel_xRow.SellingStockShippedQty <= 1)
    {
        this.PublishInfoMessage("Calling CloseRelease: " + ttOrderRel_xRow.OrderNum + "-" + ttOrderRel_xRow.OrderLine + "-" + ttOrderRel_xRow.OrderRelNum, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "CustShip", "Update");

        using (Erp.Contracts.SalesOrderSvcContract soSvc =  Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
        {
            soSvc.CloseRelease(ttOrderRel_xRow.OrderNum, ttOrderRel_xRow.OrderLine, ttOrderRel_xRow.OrderRelNum);
        }
    }
}

Just a wild guess, but does being an in-transaction DD cause problems? Since the In-trans affects the temp table, and your code is trying to make a call to the real table, is there some sort of chicken and egg thing going on?

I don’t understand the lifecycle enough but it seems like the fact that it’s in in-transaction DD could be causing problems.

Unfortunately I can’t make it work in a Method directive either for different reasons.

How about as two separate DD’s.

One In-Tran to do what needs to be done “in-tran” and another standard DD that monitors the results of the In-Tran one (after they’re completed), that does the actual closing.