Skip to main content
Solved

Using the StockItem Attribute for a Custom Field

  • January 29, 2025
  • 4 replies
  • 59 views

I’m trying to add a field to the SOLine DAC (field: CopyFromItemID) which will be used for another purpose and needs to be different than the InventoryID field used on SOLine. I figured it would be easy to just re-use the StockItem attribute for a quick and easy selector. But I’m running into an error message and I’m not sure why. It’s a very simple setup, here is the added field to the SOLineExt DAC:
 

    public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region UsrCopyFromItemID
[PXDBInt]
[StockItem]
[PXUIField(DisplayName="CopyFromItemID")]
public virtual int? UsrCopyFromItemID { get; set; }
public abstract class usrCopyFromItemID : PX.Data.BQL.BqlInt.Field<usrCopyFromItemID> { }
#endregion
}

 

The I’ve added the selector to the Sales Order page (in the Tab > Detail section) and published. However whenever I go to load a previously saved Sales Order, I always end up with this error message.
 

 

If I start new and populate the fields I get a different error message:

 

 

I must obviously be missing some important detail here and I’m not sure what. I have this in a fresh instance with no other customizations. Anyone have any thoughts?

Best answer by Django

One thing to watch it to see if [StockItem] is already defining the [DBPXInt] attribute.

 

My SOLine has

[SOLineInventoyrItem(Filterable=true)]

for the attribute and it do not have [PXDBInt].  I suspect if you remove [PXDBInt] it will work.

4 replies

Forum|alt.badge.img+7
  • Captain II
  • January 29, 2025

Just to confirm - is the UsrCopyFromItemID field in the SQL database an Int field?


  • Author
  • January 29, 2025

@Django : Correct. From SSMS showing the column in the SOLine table:
 

 


Forum|alt.badge.img+7
  • Captain II
  • Answer
  • January 29, 2025

One thing to watch it to see if [StockItem] is already defining the [DBPXInt] attribute.

 

My SOLine has

[SOLineInventoyrItem(Filterable=true)]

for the attribute and it do not have [PXDBInt].  I suspect if you remove [PXDBInt] it will work.


  • Author
  • January 30, 2025

@Django : That must have been it, seems to be working now.

Thanks so much!