2
votes

We are trying to implement an "InventoryCD" (string) field in a custom page (not an Inventory ID Int field). We need this InventoryCD field to to work just like the Stock Item InventoryCD field (field mask for segment display and selector for existing items). Currently the issue is the same aspx PXSegmentMask and DAC attributes are not working the same. We are using InventoryRawAttribute on our field the exact same way found on the InventoryItemMaint cache attached for InventoryItem.InventoryCD. The only exception is the Inventory CD field is NOT a key in our custom page.

Our problem is the display of our Inventory CD field for the segment mask only displays when we are not entering or focused on the field (user has to click move to another field). This makes it difficult for users to follow which segments they are entering values into. So my question is what are we missing?

Here is what we have done so far:

(1) DAC - InventoryCD (same as InventoryItem.InventoryCD from InventoryItemMaint cache attached - except IsKey = false):

public abstract class inventoryCD : PX.Data.IBqlField
{}

protected String _InventoryCD;

[PXDefault()]
[InventoryRaw(typeof(Where<InventoryItem.stkItem, Equal<True>>), DisplayName = "Inventory ID", Filterable = true)]
public virtual String InventoryCD
{
    get
    {
        return this._InventoryCD;
    }
    set
    {
        this._InventoryCD = value;
    }
}

(2) Page - InventoryCD (Copied from stock items IN202500):

<px:PXSegmentMask ID="edInventoryCD" runat="server" DataField="InventoryCD" 
    DataSourceID="ds" AutoRefresh="true" > 
    <GridProperties FastFilterFields="InventoryCD,Descr" />
</px:PXSegmentMask>

Here is a sample of the results I am seeing (refer to the image below). Note what the fields look like when entering values or just clicking into the field. On our custom page, clicking into the Inventory CD field shows no segmented separation. Doing the same on the Stock Item page will show the segmented separation so the user can following the segments. How do we get the segmented display to work in our custom page?

Input fields image

EDIT: If you set ValidComboRequired = true in InventoryRawAttribute the mask displays correctly the same as stock item, however you loose the selector for all items and the selector then becomes a selector for each item segment value (making the issue worse). Just an FYI in case anyone can see some type of combination I need as it might relate to ValidComboRequired (the mask when true, and the selector when false).

EDIT2: Tried making the field a key (but not the only key in the DAC) and no difference

3

3 Answers

3
votes

To get input mask, you can set AutoComplete to false in aspx without customizing out-of-box InventoryRaw attribute.

Example:

using PX.Data;
using PX.Objects.IN;

namespace PXDemoPkg
{
    public class INSetupDemoExt : PXCacheExtension<INSetup>
    {
        public abstract class usrInventoryID : IBqlField { }

        #region UsrInventoryID
        [PXDefault]
        [PXUIField(DisplayName = "InventoryID")]
        [InventoryRaw(typeof(Where<InventoryItem.stkItem, Equal<True>>), 
                        DisplayName = "Inventory ID", Filterable = true)]
        public virtual string UsrInventoryID { get; set; }

        #endregion
    }
}

enter image description here

enter image description here

1
votes

Ruslan's post is an answer if limited to using the standard framework attributes, there is not a way to trigger the display I need.

However, I had to create my own InventoryRawAttribute for other reasons not related to my question. In doing so I set the PXDimensionSelectorAttrbiute.SelectorMode to MaskAutocomplete and this made the field function exactly the way I need it to.

He is the stripped down basics to get this working. This is a copy of InventoryRawAttribute and added the attr.SelectorMode = PXSelectorMode.MaskAutocomplete.

/// <summary>
/// Copy of InventoryRawAttribute (sealed class)
/// </summary>
[PXDBString(InputMask = "", IsUnicode = true)]
[PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.SelectorVisible)]
public sealed class TestInventoryRawAttribute : AcctSubAttribute
{
    public const string DimensionName = "INVENTORY";

    public TestInventoryRawAttribute()
        : base()
    {
        Type SearchType = typeof(Search<InventoryItem.inventoryCD, Where<Match<Current<AccessInfo.userName>>>>);
        PXDimensionSelectorAttribute attr = new PXDimensionSelectorAttribute(DimensionName, SearchType, typeof(InventoryItem.inventoryCD));
        attr.CacheGlobal = true;
        // This is the secret sauce - MaskAutocomplete
        attr.SelectorMode = PXSelectorMode.MaskAutocomplete;
        _Attributes.Add(attr);
        _SelAttrIndex = _Attributes.Count - 1;
    }
}

The secret sauce in action...

Screen shot of working UI for Inventory CD field

0
votes

The reported behavior of PXSegmentMask is by design. If you play with Business Accounts a little and define at least 2 segments for the BIZACCT segmented key, on the Sales Orders screen there will also be no segmented separation in the Customer ID lookup until it loses focus:

enter image description here

enter image description here

With ValidComboRequired property set True on InventoryRawAttribute, you tell PXSegmentMask to work in "per-segment" mode, which disables the selector for all items and forces it to become a selector for each item segment value.

Inventory ID is a key field on the Stock Items screen as well as Customer ID is a key on the Customers screen, and therefore on both of this screens segment separation exists along with the selector for all items. The reason I referred to the Customer lookup on the Sales Orders screen is because CustomerID is not a key field for the SOOrder DAC, which is the main reason why segmented separation is missing in the Sales Order's Customer ID lookup until it loses focus.