Skip to main content
Solved

Exposing Inventory Summary Available to Ship field to StockItem endpoint


amitr70
Semi-Pro I
Forum|alt.badge.img

Hi , I wanted to extend  my stock item end point to include Available to Ship value of Inventory Summary screen. To do so, I Create a custom view and tried to populate the field from DAC level only. So that when called from API it will resolve the BQL and fire the data to the API. I want this field for API only so I dont have any screen level events attached to this DAC field.

Below is my code

 public class TSInventoryItemNIExtension : PXCacheExtension<PX.Objects.IN.InventoryItem>
 {
     public static bool IsActive() => true;
     #region UsrAvailToShip
     [PXDBDecimal]
     [PXSelector(typeof(
     Search<TSViewGetAvailToShip.qtyHardAvail,
         Where<TSViewGetAvailToShip.inventoryID, Equal<Current<InventoryItem.inventoryID>>>>))]
     [PXUIField(DisplayName = "Avail To Ship")]

     public virtual decimal? UsrAvailToShip { get; set; }
     public abstract class usrAvailToShip : PX.Data.BQL.BqlDecimal.Field<usrAvailToShip> { }
     #endregion
 }

In the above DAC TSViewGetAvailToShip is a Sql view that return a list all StockItems with QtyHardAvail from INSiteStatus table. I used PXDBScalar , PXDBCalced, PXDefault etc. But no success. With PXDBScalar , I was able to get correct data but that choked my StockItem screen with an error @P0 parameter is expected. With DBCalced , I was getting error “Specified cast is invalid”. With PXDefault no error but always 0 as value. 
Please help. 

Best answer by amitr70

Thanks All for your responses.  Appreciate that. I was able to achieve this but through a longer way. And that was I added a tab for with a grid on it displaying that DAC values and exposed that to API endpoint. Also, I needed the value as a sum so there's no need of Warehouses /Locations. 

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

6 replies

Forum|alt.badge.img+6
  • Captain II
  • 563 replies
  • March 5, 2025

Can we see the DAC for your TSViewGetAvailToShip?


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • 30 replies
  • March 6, 2025

@Django  Here it is

 

using PX.Data;
using System;

namespace EMPApp.DAC
{

    [Serializable]
    [PXCacheName("TSViewGetAvailToShip")]
    public class TSViewGetAvailToShip : IBqlTable
    {
        #region InventoryID
        [PXDBInt()]
        [PXUIField(DisplayName = "Inventory ID")]
        public virtual int? InventoryID { get; set; }
        public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
        #endregion

        #region InventoryCD
        [PXDBString(30, IsUnicode = true, InputMask = "")]
        [PXUIField(DisplayName = "Inventory CD")]
        public virtual string InventoryCD { get; set; }
        public abstract class inventoryCD : PX.Data.BQL.BqlString.Field<inventoryCD> { }
        #endregion

        #region Descr
        [PXDBString(256, IsUnicode = true, InputMask = "")]
        [PXUIField(DisplayName = "Descr")]
        public virtual string Descr { get; set; }
        public abstract class descr : PX.Data.BQL.BqlString.Field<descr> { }
        #endregion

        #region QtyOnHand
        [PXDBDecimal()]
        [PXUIField(DisplayName = "Qty On Hand")]
        public virtual Decimal? QtyOnHand { get; set; }
        public abstract class qtyOnHand : PX.Data.BQL.BqlDecimal.Field<qtyOnHand> { }
        #endregion

        #region QtyAvail
        [PXDBDecimal()]
        [PXUIField(DisplayName = "Qty Avail")]
        public virtual Decimal? QtyAvail { get; set; }
        public abstract class qtyAvail : PX.Data.BQL.BqlDecimal.Field<qtyAvail> { }
        #endregion

        #region QtyHardAvail
        [PXDBDecimal()]
        [PXUIField(DisplayName = "Qty Hard Avail")]
        public virtual Decimal? QtyHardAvail { get; set; }
        public abstract class qtyHardAvail : PX.Data.BQL.BqlDecimal.Field<qtyHardAvail> { }
        #endregion
    }
}

 


Melissalutrick21
Freshman II

Django,

Hope you are well!

Do you have multiple warehouses? You may want to include SITE in the data set so it pulls from a set warehouse. If believe when working with quantities, I run into needing the SITEID (Warehouse) as one of my top issues.

Cheers,

Melissa

 


Samvel Petrosov
Jr Varsity II
Forum|alt.badge.img+5

PXSelector will not work the way you need it in this case. PXDefault is closer to what you need, but the problem is that it will not be triggered as your record already exists and correspondingly there is nothing that needs defaulting.

 

Have you tried using PXFormulaAttribute? You can use it in combination with Selector<> to get to your record TSViewGetAvailToShip and read the value of that QtyHardAvail field.

But that will require a selector attribute on some proper of the InventoryItem table that links back to your record.

 

Below is an example of how that is used to set the Inventory Account value from the Posting Class.

[Account(DisplayName = "Inventory Account", Visibility = PXUIVisibility.Visible, DescriptionField = typeof(Account.description), ControlAccountForModule = "IN")]
[PXFormula(typeof(Selector<InventoryItem.postClassID, INPostClass.invtAcctID>))]
[PXForeignReference(typeof(InventoryItem.FK.InventoryAccount))]
public virtual int? InvtAcctID


 


amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • 30 replies
  • Answer
  • March 11, 2025

Thanks All for your responses.  Appreciate that. I was able to achieve this but through a longer way. And that was I added a tab for with a grid on it displaying that DAC values and exposed that to API endpoint. Also, I needed the value as a sum so there's no need of Warehouses /Locations. 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2759 replies
  • March 11, 2025

Thank you for sharing your solution with the community ​@amitr70!


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