Skip to main content
Answer

Add Inventory Item Attribute to the Sales Order Line Items

  • May 22, 2023
  • 2 replies
  • 681 views

I am wanting to get the value from an attribute for a inventory stock item. The attribute is showing under Attributes tab when editing the inventory item (IN202500). The type is text.

I am trying to make the value show on the Sales Order Line grid. I have added a data field usrBrand, and it is showing the column. My problem is that I can’t figure out how to make the brand value show in the Sales Order Line Items grid

 

Best answer by Patrick Chen

So, if you are not aware, all attribute values are stored in a table called CSAnswers.  Every entry has a RefNoteID that links to the object’s Noteid (your particular inventoryItem’s noteid) and an attribute ID that identifies the particular attribute type(Brand in your example above).  Here is an example bql query to get you started

 

var attributes = SelectFrom<SOLine>

                    .InnerJoin<InventoryItem>.On<SOLine.inventoryID.IsEqual<InventoryItem.inventoryID>>

                    .LeftJoin<CSAnswers>.On<CSAnswers.refNoteID.IsEqual<InventoryItem.noteID>

                        .And<CSAnswers.attributeID.IsEqual<CustomConstantwithAttributeName>>>

                   .Where<SOLine.OrderNbr.IsEqual<@P.AsString».and<soline.ordertype...
 

2 replies

Patrick Chen
Varsity II
Forum|alt.badge.img+2
  • Varsity II
  • Answer
  • May 22, 2023

So, if you are not aware, all attribute values are stored in a table called CSAnswers.  Every entry has a RefNoteID that links to the object’s Noteid (your particular inventoryItem’s noteid) and an attribute ID that identifies the particular attribute type(Brand in your example above).  Here is an example bql query to get you started

 

var attributes = SelectFrom<SOLine>

                    .InnerJoin<InventoryItem>.On<SOLine.inventoryID.IsEqual<InventoryItem.inventoryID>>

                    .LeftJoin<CSAnswers>.On<CSAnswers.refNoteID.IsEqual<InventoryItem.noteID>

                        .And<CSAnswers.attributeID.IsEqual<CustomConstantwithAttributeName>>>

                   .Where<SOLine.OrderNbr.IsEqual<@P.AsString».and<soline.ordertype...
 


darylbowman
Captain II
Forum|alt.badge.img+15

Additionally, you could possibly use a [PXDBScalar()] DAC attribute or else the FieldSelecting event for UsrBrand to set the value.