0
votes

I need to add Customer Part Number and Vendor Part Number column of InventoryID selector on Sales Order line to enable user select InventoryID by part number when creating SO Lines. Adding column from Customization Project > Customized Data Class > Selector Columns to selector can't help. So, I try to customize the attribute but still no succeed because the definition of InventoryID field on SOLine DAC is like this:

[SOLineInventoryItem(Filterable=true)]
[PXDefault()]

need help to figured how to customize this kind of attribute.

1
there can be many customer/vendor part number for an item, how do you plan to show that in the selector?Sin

1 Answers

2
votes

In Acumatica Customer and Vendor Part Numbers are stored in Cross-Reference tab on the Stock Items screen. As shown on the screenshot below, AlternateID is declared in the INItemXRef DAC and there is one-to-many relationship between the InventoryItem and the INItemXRef DACs: enter image description here

With that said, it's not possible to add Customer and Vendor Part Number columns into InventoryID selector as this will result in duplicated InventoryItem records.

An alternative solution is to create a custom text field in the InventoryItem DAC, then override Persist in the InventoryItemMaint BLC extension to concatenate Alternate IDs and store result in custom text field (DB column):

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint>
{
    [PXOverride]
    public void Persist(Action del)
    {
        using (PXTransactionScope ts = new PXTransactionScope())
        {
            InventoryItem item = Base.Item.Current;
            if (item != null && Base.itemxrefrecords.Cache.IsDirty)
            {
                string alternateIDs = string.Empty;
                foreach (INItemXRef crossRef in Base.itemxrefrecords.Select())
                {
                    alternateIDs = string.IsNullOrEmpty(alternateIDs) ?
                        crossRef.AlternateID : alternateIDs + "; " + crossRef.AlternateID;
                }
                item.GetExtension<InventoryItemExt>().UsrAlternateIDs = alternateIDs;
                Base.Item.Update(item);
            }

            del();
            ts.Complete();
        }
    }
}

To simplify initial setup you can also implemented RecalcAlternateIDs action in the InventoryItemMaint BLC extension. The RecalcAlternateIDs action will loop though all Stock Items in the application and concatenate Alternate IDs:

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint>
{
    ...

    public PXAction<InventoryItem> RecalcAlternateIDs;
    [PXButton]
    [PXUIField(DisplayName = "Concatenate Alternate IDs")]
    protected void recalcAlternateIDs()
    {
        PXLongOperation.StartOperation(Base, () =>
        {
            InventoryItemMaint itemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
            var items = PXSelect<InventoryItem, Where<InventoryItem.stkItem, Equal<boolTrue>>>.Select(itemMaint);
            foreach (InventoryItem item in items)
            {
                itemMaint.Clear();
                itemMaint.Item.Current = item;
                itemMaint.itemxrefrecords.Cache.IsDirty = true;
                itemMaint.Actions.PressSave();
            }
        });
    }
}

By default all selector controls build search indexes against key (or SubstituteKey when defined) and description, if defined, fields. To extend this list, you can either set FilterByAllFields property to True for PXSelector/PXSegmentMask control in Aspx or utilize FastFilterFields following the steps below. In my opinion, FastFilterFields seems like a better option to address your request.

Next steps are required to add UsrAlternateIDs column into InventoryID selector

  1. Launch Layout Editor for the Sales Orders screen (SO301000) and select Edit Aspx option from the Actions menu:

enter image description here

  1. In Aspx file locate declaration of the InventoryID selector:

    <px:PXSegmentMask CommitChanges=“True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" /> 
    
  2. For the InventoryID selector, append columns by declaring the UsrAlternateIDs column, then click Generate Customization Script:

    <px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
        <GridProperties FastFilterFields="UsrAlternateIDs">
            <Columns>
                <px:PXGridColumn DataField="UsrAlternateIDs" AutoGenerateOption="Add" Width="250px" />
            </Columns>
        </GridProperties>
    </px:PXSegmentMask>