0
votes

Acumatica - Attempting to add INItemXRef AlternatID to universal search.

I did look at another question that seemed to possibly be a duplicate of my question, but Acumatica gave him a different approach and he has not gotten any responses, hoping to have better luck:

Adding INItemXRef to Global Search with Inventory Item

The goal is a universal search by customer item number. Acumatica advised to create a dummy INItemXRef maintenance screen and add a searchable NoteID to the DAC to reference this screen. Below is my first stab at adding the NoteID, but I'm getting compilation errors:

   public class INItemXRefExt : PXCacheExtension<PX.Objects.IN.INItemXRef>
   {
    #region NoteID    
    [PXDBGuid]
    [PXUIField(DisplayName="NoteID")]
    [PXSearchable(SM.SearchCategory.IN, 
        "{0}: {1}", 
        new Type[] { typeof(INItemXRef.alternateType), typeof(INItemXRef.inventoryID)},
        new Type[] { typeof(INItemXRef.descr), typeof(INItemXRef.alternateID) }, // add fields you want to be searchable
        NumberFields = new Type[] { typeof(INItemXRef.inventoryID) },
        Line1Format = "{0}{1}", Line1Fields = new Type[] { typeof(INItemClass.itemClassCD), typeof(INItemXRef.alternateID)},
        Line2Format = "{0}", Line2Fields = new Type[] { typeof(INItemXRef.descr) },
        //WhereConstraint = typeof(Where<Current<InventoryItem.itemStatus>, NotEqual<InventoryItemStatus.unknown>>),
        SelectForFastIndexing = typeof(Select<INItemXRef>)  // this is required so that search knows how to index your fields
      )]
      //[PXNote(PopupTextEnabled = true)]
      //public Guid? NoteID { get; set; }
      public virtual Guid? NoteID { get; set; }
      public abstract class NoteID : IBqlField { }
    #endregion
   }

When compiling I get this validation error: \App_RuntimeCode\INItemXRef.cs(28): error CS0102: The type 'PX.Objects.IN.INItemXRefExt' already contains a definition for 'NoteID'

I thought at first that the reason is because the field was already created in a previous run (I think it was), and the public abstract class NoteID : IBqlField { } was essentially trying to get it to duplicate the field. So I commented out the line and got this:

The base property is missed or IBqlField is not defined: NoteID in extension PX.Objects.IN.INItemXRefExt

I'm sure there are plenty of problems with my searchable attribute as well and will update the question as it evolves, but for the moment I'm stumped at the compilation step.

Update:

Thanks to the responses below I was able to re-write a bit and get everything to compile. Next step is to figure out why the results are a bit strange. interestingly, I cannot do a universal search and find any item unless it has a cross-reference, and then only displays base item info even though I'm trying to display the alternate code(s) and descriptions(s). New code:

#region NoteID
    public abstract class noteID : PX.Data.IBqlField
    {
    }
    protected Guid? _NoteID;
    [PXSearchable(SM.SearchCategory.IN, 
        "{0}: {1}", 
        new Type[] { typeof(INItemXRef.alternateType), typeof(INItemXRef.inventoryID)},
        new Type[] { typeof(INItemXRef.descr), typeof(INItemXRef.alternateID) }, // add fields you want to be searchable
        NumberFields = new Type[] { typeof(INItemXRef.inventoryID) },
        Line1Format = "{0}{1}", Line1Fields = new Type[] { typeof(INItemClass.itemClassCD), typeof(INItemXRef.alternateID)},
        Line2Format = "{0}", Line2Fields = new Type[] { typeof(INItemXRef.descr) },
        //WhereConstraint = typeof(Where<Current<InventoryItem.itemStatus>, NotEqual<InventoryItemStatus.unknown>>),
        SelectForFastIndexing = typeof(Select<INItemXRef>)  // this is required so that search knows how to index your fields
    )]
    [PXNote(DescriptionField = typeof(INItemXRef.inventoryID), 
        Selector = typeof(INItemXRef.inventoryID))]
    public virtual Guid? NoteID
    {
        get
        {
            return this._NoteID;
        }
        set
        {
            this._NoteID = value;
        }
    }
    #endregion
2
In your code you have NoteID first letter uppercase twice. Guid should be NoteID uppercase and the abstract class should be noteID first letter lowercase.Hugues Beauséjour
I noticed that in the code from cbetabeta as well, makes sense considering that's how the rest of the types/properties in Acumatica seem to work.Alan Atkins

2 Answers

1
votes

You can review one of the out-of-the-box DAC that contains NoteID field and review it for guidance. For example, take a look at the INRegister.NoteID field definition:

#region NoteID
    public abstract class noteID : PX.Data.IBqlField
    {
    }
    protected Guid? _NoteID;
    [PXSearchable(SM.SearchCategory.IN, "{0}: {1}", new Type[] { typeof(INRegister.docType), typeof(INRegister.refNbr) },
        new Type[] { typeof(INRegister.tranDesc), typeof(INRegister.extRefNbr), typeof(INRegister.transferNbr) },
        NumberFields = new Type[] { typeof(INRegister.refNbr) },
        Line1Format = "{0}{1:d}{2}{3}{4}", Line1Fields = new Type[] { typeof(INRegister.extRefNbr), typeof(INRegister.tranDate), typeof(INRegister.transferType), typeof(INRegister.transferNbr), typeof(INRegister.status) },
        Line2Format = "{0}", Line2Fields = new Type[] { typeof(INRegister.tranDesc) },
        WhereConstraint = typeof(Where<INRegister.docType, NotEqual<INDocType.production>, And<INRegister.docType, NotEqual<INDocType.disassembly>>>)
    )]
    [PXNote(DescriptionField = typeof(INRegister.refNbr), 
        Selector = typeof(INRegister.refNbr))]
    public virtual Guid? NoteID
    {
        get
        {
            return this._NoteID;
        }
        set
        {
            this._NoteID = value;
        }
    }
    #endregion

Notice the use of PXNote attribute(and no use of PXDBGuid attribute). You can try similar approach and only with PXNote first, to confirm it compiles properly. Then you could add PXSearcheable and start working on it.

0
votes

This particular question has been answered, but in order to get the search to work the way I need will have to go a different direction creating a brand-new DAC, BLC, and maintenance screen. Thanks for the help!