如何将自定义字段包含到全文实体索引中?

How to include a custom field into Full-Text Entity Index?

客户希望使用通用搜索框来搜索自定义字段中的值。如何才能做到这一点?

在本例中,我为 InventoryItem 创建了一个简单的自定义文本字段。目前,它在 UI.

中不可见

让我们参考在 中创建的自定义 UsrAlternateIDs 字段,并将其包含到 Acumatica 的全文实体索引中。

将 UsrAlternateIDs 字段包含到全文实体索引中所需的唯一修改是替换 PXSearchableAttributeNoteID[=26= 上使用的原始声明] InventoryItem DAC 中的字段。如下面的代码片段所示,UsrAlternateIDs 现在包含在作为第 3 个传递的 fields 类型数组中新 PXSearchableAttribute 构造函数的参数:

[PXNonInstantiatedExtension]
public class InventoryItemExt : PXCacheExtension<PX.Objects.IN.InventoryItem>
{
    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXRemoveBaseAttribute(typeof(PXSearchableAttribute))]
    [PXSearchable(SM.SearchCategory.IN, "{0}: {1}", 
        new Type[] {
            typeof(InventoryItem.itemType),
            typeof(InventoryItem.inventoryCD) },
        new Type[] {
            typeof(InventoryItem.descr),
            typeof(InventoryItemExt.usrAlternateIDs) },
        NumberFields = new Type[] {
            typeof(InventoryItem.inventoryCD),
            typeof(InventoryItemExt.usrAlternateIDs) },
        Line1Format = "{0}{1}{2}", 
        Line1Fields = new Type[] {
            typeof(INItemClass.itemClassCD),
            typeof(INItemClass.descr),
            typeof(InventoryItem.baseUnit) },
        Line2Format = "{0}", 
        Line2Fields = new Type[] {
            typeof(InventoryItem.descr) },
        WhereConstraint = typeof(Where<Current<InventoryItem.itemStatus>, 
            NotEqual<InventoryItemStatus.unknown>>)
     )]
     public Guid? NoteID { get; set; }
}

按照上述示例实施 InventoryItem 扩展并在您的 Acumatica ERP 实例上重建全文实体索引后,应该可以根据它们搜索库存项目备用 ID。