Skip to main content
Solved

Updating the Stock Item from the Kit Assembly?


DewaldH
Jr Varsity II

Good day every one,

In my customization I have extended the KitAssemblyEntry (KitAssemblyEntry_Extension) and added an event handler to the release action:

 [PXOverride]
        public PXAction<INKitRegister> release;
        [PXProcessButton(CommitChanges = true)]
        [PXUIField(DisplayName = Messages.Release, MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
        public virtual IEnumerable Release(PXAdapter adapter)
        {
            //Base.Document.Ask("Application date does not equal to Business date, do you really want to release payment?", MessageButtons.OK);
            INKitRegister kitRegister = (INKitRegister)Base.Caches[typeof(INKitRegister)].Current;
            InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, kitRegister.KitInventoryID);

            inventoryItem.Descr = "Update from Kit Assembly";
            // Update the InventoryItem in the database
            Base.Caches[typeof(InventoryItem)].Update(inventoryItem);

            // Save changes to the database
            Base.Actions.PressSave();

            //return adapter.Get();
            return Base.release.Press(adapter);
        }

I am trying to update the Stock Item (InventoryItem) from the Kit Assembly when the Release action is pressed?

I am not sure why this is not working?

Thanks

Best answer by DewaldH

I found the issue - I was using the actual DAC instead of the name.

Here is a cleaner version of this code:

 

InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, kitRegister.KitInventoryID);

inventoryItem.Descr = "Update from Kit Assembly";

PXCache cache = Base.Caches[typeof(InventoryItem)];
cache.Update(inventoryItem);
cache.Persist(inventoryItem, PXDBOperation.Update);

 

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

2 replies

DewaldH
Jr Varsity II
  • Author
  • Jr Varsity II
  • 9 replies
  • Answer
  • October 21, 2023

I found the issue - I was using the actual DAC instead of the name.

Here is a cleaner version of this code:

 

InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, kitRegister.KitInventoryID);

inventoryItem.Descr = "Update from Kit Assembly";

PXCache cache = Base.Caches[typeof(InventoryItem)];
cache.Update(inventoryItem);
cache.Persist(inventoryItem, PXDBOperation.Update);

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2757 replies
  • October 22, 2023

Thank you for sharing your solution with the community @DewaldH!


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