Skip to main content
Solved

InventoryID vs InventoryCD on custom DAC exposed to Web Service Endpoint.


I have a created a new SQL database table/DAC/Graph to collect some information that will be related to Stocked Items from an outside application. I have extended the Default web services endpoint to include this information. This all works well.

My issue is that the custom DAC has a property for InventoryID but it expects an integer value which no one knows, they only know the item number. I have also added a property to the DAC for InventoryCD which is also exposed to the API, I can write to this just fine. Problem is that I can’t join this DAC to others in a GI since all the other DACs want to link on InventoryID.

How do I merge these 2 into 1 so that the json payload can submit the InventoryCD and the DAC translate this and store the appropriate integer value. 

Here is the current DAC definition for these fields:

        #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

Best answer by jcard64

Thanks for the response. 

I also got it to work using this definition for InventoryID and eliminating the InventoryCD from my custom DAC:

        #region InventoryID
        public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }

        protected Int32? _InventoryID;
        [StockItem(Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault]
        [PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
        public virtual Int32? InventoryID
        {
            get
            {
                return this._InventoryID;
            }
            set
            {
                this._InventoryID = value;
            }
        }
        #endregion

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

2 replies

praveenpo
Semi-Pro II
Forum|alt.badge.img+3
  • Semi-Pro II
  • 99 replies
  • February 7, 2025

Hi ​@jcard64,

You can use like below

  [PXDBIntAttribute(IsKey = true)]
        [PXUIField(DisplayName = "Inventory ID")]
        [PXDBDefault(typeof(InventoryItem.inventoryID), DefaultForUpdate = false)]
        [PXSelector(
                  typeof(Search<InventoryItem.inventoryID, Where<InventoryItem.inventoryID, NotEqual<Current<InventoryItem.inventoryID>>, And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.inactive>,
                      And<InventoryItem.stkItem, Equal<True>, And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.noSales>>>>>>),
                  typeof(InventoryItem.inventoryCD),
                  typeof(InventoryItem.descr),
                  SubstituteKey = typeof(InventoryItem.inventoryCD), DescriptionField = typeof(InventoryItem.descr))]
        public virtual int? InventoryID { get; set; }
        public abstract class inventoryID : BqlInt.Field<inventoryID> { }

declare the InventoryID field with Int and give substitute as InventoyCD

This will work in your case


  • Author
  • Freshman II
  • 1 reply
  • Answer
  • February 7, 2025

Thanks for the response. 

I also got it to work using this definition for InventoryID and eliminating the InventoryCD from my custom DAC:

        #region InventoryID
        public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }

        protected Int32? _InventoryID;
        [StockItem(Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault]
        [PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
        public virtual Int32? InventoryID
        {
            get
            {
                return this._InventoryID;
            }
            set
            {
                this._InventoryID = value;
            }
        }
        #endregion


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