0
votes

I am trying to divide values and display it in a new custom field(usrQuantity)on Stock Items Screen.

I want to divide OpenQty (which is a column in POLine) and CARTONQTY(which is not a column name but just an attribute in column AttributeID in CSAnswers table).

enter image description here I am confused how to perform this division since CARTONQTY is not a field, I noticed that there is a field named CARTONQTY_Attributes in InventoryItem table which has been generated by some Join queries but is not actually present in the Database(checked in SQL Management Studio).

enter image description here

I tried this formula in the DAC of usrQuantity

[PXDBInt]
[PXUIField(DisplayName="Quantity")]
[PXFormula(typeof(Div<POLine.orderQty,InventoryItem.CARTONQTY_Attributes>))]

But it is giving following errors The type or namespace name 'POLine' could not be found (are you missing a using directive or an assembly reference?)

The type name 'CARTONQTY_Attributes' does not exist in the type 'PX.Objects.IN.InventoryItem'

1

1 Answers

0
votes

Do you want to store the value in the db? Typically it's not recommended practice to persist calculated values unless, for example, there's a performance issue in performing the calculation on the fly. If you don't want to store it, you probably want a PXInt instead of PXDBInt. Also, unless you always expect a whole number as a result of your division (which is unlikely), you should probably use a PXDecimal type.

To then get your calculated value into your new field, I would probably set it in RowSelecting and RowUpdated event handlers by extending the appropriate PXGraph class; in order to calculate it as you retrieve a row and when you update the row values.