Skip to main content

We have a customer that has requested that the Related Items screen automatically open in the Sales Order screen if a user enters an inventory id that has related items to choose from.  Our developer has looked into this.  He was able to get the related items screen to automatically open but the changes that the dialog is supposed to apply are lost somehow because we are doing this in the middle of the row update.

Has anyone been able to achieve this or have any advice?

Hi 

I assume that you added a popup when clicking on the inventoryID, In the popup Add a Button as Add or OK (Refer to the screenshot). In the Add/OK button, Add the code to insert the related item load on the Soline.
 


Sample Code for the OK/Add button:

public PXAction<SOOrder> RelatedProductsOK;
         PXButton]
        ÂPXUIField(DisplayName = "Related Items")]
        protected virtual void relatedProductsOK()
        {         
          InventoryItemFilter.AskExt();

            if (InventoryItemFilter.Cache.Inserted.Cast<InventoryItemFilter>().Count() > 0)
            {
                if (InventoryItemFilter.AskExt() == WebDialogResult.OK)
                {
                    foreach (InventoryItemFilter invt in InventoryItemFilter.Cache.Inserted)
                    {
                          if (invt.Selected==true)
                        {
                            SOLine newline = PXCache<SOLine>.CreateCopy(Base.Transactions.Insert(new SOLine()));
                            newline.InventoryID = invt.InventoryID;
                            newline.OrderQty = 1;
                            newline.SiteID = invt.DfltSiteID;
                            Base.Transactions.Cache.Update(newline);

                            InventoryItemFilter.Cache.SetValueExt<InventoryItemFilter.selected>(invt, false);
                        }
                    }
                }
            } 


Thanks for the information.  Our developer had to do some additional work because the Related Items pop up screen was a little more complicated, but he was able to get it working.


Reply