1
votes

I am trying to add INItemXRef's Alternate ID to the global search for Inventory Item profiles. This is a 1:many relationship since there can be various vendors and units of measure with different Alternate ID's.

Per Acumatica, I have tried replacing the NoteID for Inventory Item with a match with join with the below code:

[PXSearchable(SM.SearchCategory.IN, "{0}: {1}", new Type[] { 
  typeof(InventoryItem.itemType), typeof(InventoryItem.inventoryCD) },
  new Type[] { typeof(InventoryItem.descr) },
  NumberFields = new Type[] { typeof(InventoryItem.inventoryCD) },
  Line1Format = "{0}{1}{2}", Line1Fields = new Type[] { 
    typeof(INItemClass.itemClassCD), typeof(INItemClass.descr), 
    typeof(INItemXRef.alternateID) },
  Line2Format = "{0}", Line2Fields = new Type[] { 
    typeof(InventoryItem.descr)},
  MatchWithJoin = typeof(RightJoin<INItemXRef, On<INItemXRef.inventoryID, 
    Equal<InventoryItem.inventoryID>>>),
  WhereConstraint = typeof(Where<Current<InventoryItem.itemStatus>, 
  NotEqual<InventoryItemStatus.unknown>>)
)]
[PXNote(PopupTextEnabled = true)]

I've also followed the example from question How to include field from a linked entity into Full-Text Entity Index?

My code for this in Inventory Item's DAC extension is:

public partial class INItemXRef: PX.Data.IBqlTable
{  
  //, IPaymentTypeDetailMaster, ILocation
    public abstract class inventoryID: IBqlField { }
    [PXDBInt()]
    [PXDBChildIdentity(typeof(INItemXRef.inventoryID))]
    [PXUIField(DisplayName = "Xref ID", Visibility = PXUIVisibility.Invisible)]
    [PXSelector(typeof(Search<INItemXRef.inventoryID>), DirtyRead = true)]
    public virtual int? InventoryID{ get; set; } 
    //public virtual void InventoryItem_InventoryID_CacheAttached(PXCache sender)
    //{
    //} 

    public abstract class alternateID: IBqlField { }
    [PXDBString()]
    [PXUIField(DisplayName = "Alternate ID")]
    public virtual int? AlternateID{ get; set; }              
}

However, the correct way to do this is still and issue. There has been one suggestion to use CacheAttached but I haven't been able to make that work, either.

Is Cache Attached actually required or am I missing something from including linked entities?

The intention is to search for a specific Inventory Item and get the Items and and Alternate ID(s) they have, meaning an Item may appear more than once in the Global Search. I have also made sure to reset IIS and rebuild full text indexes in case this was the issue.