Skip to main content
Solved

Automatically pop up the Related Items screen


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?

Best answer by jinin

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);
                        }
                    }
                }
            } 

View original
Did this topic help you find an answer to your question?

2 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 680 replies
  • Answer
  • July 31, 2023

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);
                        }
                    }
                }
            } 


  • Author
  • Freshman II
  • 8 replies
  • August 3, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings