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