Acumatica-尝试将INItemXRef AlternatID添加到通用搜索中。
我确实看过另一个问题,似乎与我的问题重复,但是Acumatica给了他一种不同的方法,他没有得到任何回应,希望能有更好的运气:
Adding INItemXRef to Global Search with Inventory Item
目标是按客户物料号进行通用搜索。建议Acumatica创建一个虚拟的INItemXRef维护屏幕,并向DAC添加可搜索的NoteID以引用该屏幕。以下是我添加NoteID的第一个步骤,但出现编译错误:
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
}
编译时出现此验证错误: \ App_RuntimeCode \ INItemXRef.cs(28):错误CS0102:类型“ PX.Objects.IN.INItemXRefExt”已经包含“ NoteID”的定义
起初,我认为原因是因为该字段是在上一次运行中创建的(我认为是),而public abstract class NoteID : IBqlField { }
本质上是试图使其复制字段。所以我注释掉了这一行,得到了:
缺少基本属性或未定义IBqlField:扩展名PX.Objects.IN.INItemXRefExt中的NoteID
我确定我的searchable属性也存在很多问题,并且会随着问题的发展而更新,但目前我对编译步骤感到困惑。
更新:
由于下面的回答,我得以重新编写一些内容并进行编译。下一步是弄清楚结果为什么有些奇怪。有趣的是,除非有交叉引用,否则我无法进行通用搜索并找到任何项目,即使我试图显示替代代码和描述,也只能显示基本项目信息。新代码:
#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
答案 0 :(得分:1)
您可以查看包含NoteID字段的即用型DAC之一,并查看它以获取指导。例如,看一下INRegister.NoteID字段定义:
#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
注意使用PXNote属性(不使用PXDBGuid属性)。 您可以尝试类似的方法,并且首先仅使用PXNote,以确认它可以正确编译。然后,您可以添加PXSearcheable并开始对其进行操作。
答案 1 :(得分:0)
已经回答了这个特定问题,但是为了使搜索按我需要的方式工作,必须朝着不同的方向创建全新的DAC,BLC和维护屏幕。感谢您的帮助!