Determining when Manual Backorder Release is activated  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Determining when Manual Backorder Release is activated

Postby DannyC » Thu Mar 10, 2022 2:15 pm

I'm using the attached plugin to work out when the Manual BackOrder Release is activated.

Based on a similar method for GRNs using the same concept demonstrated here viewtopic.php?f=26&t=1584
I am hooking into the SaveStart event. Then checking the Status and OriginalStatus.

That might work for GRNs, but it isn't working for Manual BO Release.

Is there another trick to know when it's activated?

v 7.2.1
Attachments
Plugin Attkey Manual BackOrder Test Activating.xml
(35.36 KiB) Downloaded 40 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Determining when Manual Backorder Release is activated

Postby SBarnes » Thu Mar 10, 2022 4:06 pm

Below is the active code that gets used it never does a save, it just saves the header i.e. not a full save but at the end it does do a read so your best bet is to hook onto it there or on the actual forms click of the ribbon from set up before if you need to get at it before its activated.




Code: Select all
public void ActivateRecord()
        {
            IEnumerator enumerator = null;
            if (this.ChangeFlag)
            {
                throw new Exception("Please save the manual back order release batch first.");
            }
            if (this._OriginalStatus == ManualBOBatch.Statuses.Activated)
            {
                throw new Exception("This manual back order release batch is already activated.");
            }
            if (this.UpdateQuantityAvailable(true))
            {
                throw new Exception("Quantity available, back order amounts and priorities have been checked and variations have been found since this batch was last saved. These changes have now been applied to the lines.\r\n\r\nPlease go back and review the lines before activating again.");
            }
            ManualBOBatch.Statuses status = this._Status;
            bool changeFlag = this.ChangeFlag;
            try
            {
                this._Status = ManualBOBatch.Statuses.Activated;
                this.ChangeFlag = true;
                this.SaveHeader();
                StdFunctions stdFunction = null;
                stdFunction = this.Manager.BusinessLogicFactory.CreateBusinessLogic<StdFunctions>(null);
                stdFunction.ReadsAreUnCommitted = true;
                stdFunction.SetupProcessBackOrdersUnattended();
                try
                {
                    enumerator = this.BatchLines.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        BatchLine current = (BatchLine)enumerator.Current;
                        if (!current.FulfillBackOrderFlag)
                        {
                            continue;
                        }
                        try
                        {
                            string nOnBackOrderOrdersOnBackID = current.IN_OnBackOrder_OrdersOnBackID;
                            string invoiceID = this.SalesOrders[current.SalesOrderItemKey].SalesOrder.InvoiceID;
                            string invoiceLineID = current.InvoiceLineID;
                            decimal num = new decimal(current.BackOrderQuantity);
                            string inventoryID = this.InventoryItems[current.InventoryItemKey].Inventory.InventoryID;
                            string partNo = this.InventoryItems[current.InventoryItemKey].Inventory.PartNo;
                            string nLogicalID = this.Warehouse.IN_LogicalID;
                            BatchLine batchLine = current;
                            BatchLine batchLine1 = batchLine;
                            string errorMessage = batchLine.ErrorMessage;
                            stdFunction.ProcessBackOrdersForSingleSalesOrderUnattended(nOnBackOrderOrdersOnBackID, invoiceID, invoiceLineID, num, inventoryID, partNo, nLogicalID, ref errorMessage, true);
                            batchLine1.ErrorMessage = errorMessage;
                        }
                        catch (Exception exception)
                        {
                            ProjectData.SetProjectError(exception);
                            ProjectData.ClearProjectError();
                        }
                        current.Save();
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                if (this._Status == ManualBOBatch.Statuses.Activated & this._OriginalStatus == ManualBOBatch.Statuses.UnActivated)
                {
                    this.PrintReports();
                }
                this.ChangeFlag = false;
                this.Read(this.RecID);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                this.ChangeFlag = changeFlag;
                this._Status = status;
                throw;
            }
        }

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Determining when Manual Backorder Release is activated  Topic is solved

Postby DannyC » Thu Mar 10, 2022 5:21 pm

at the end it does do a read so your best bet is to hook onto it there


Just did quick test. Looks like I can use ReadStart instead of SaveStart.
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 14 guests