要在Acumatica中启用可搜索字段,您可以按照以下步骤操作:
打开Acumatica中的自定义对象的逻辑代码文件(通常是您要启用可搜索字段的数据表的扩展文件)。
导入以下命名空间:
using PX.Data;
在逻辑代码文件中,找到要启用可搜索字段的数据表的扩展类,并在该类上应用PXSearchable特性。例如,如果要在MyCustomTable表上启用可搜索字段,可以执行以下操作:
public class MyCustomTableExt : PXCacheExtension
{
#region Searchable Fields
public abstract class usrSearchField1 : IBqlField { }
[PXSearchable(PX.Objects.SM.SearchCategory.BAccount, "Custom Search Field 1", new Type[] { typeof(MyCustomTable.field1), typeof(MyCustomTable.field2) },
new Type[] { typeof(MyCustomTable.field1), typeof(MyCustomTable.field2) },
NumberFields = new Type[] { typeof(MyCustomTable.field3) },
Line1Format = "{0}{1}", Line1Fields = new Type[] { typeof(MyCustomTable.field1), typeof(MyCustomTable.field2) },
Line2Format = "{0}", Line2Fields = new Type[] { typeof(MyCustomTable.field3) })]
public virtual string UsrSearchField1 { get; set; }
#endregion
}
在此示例中,PXSearchable特性将在MyCustomTable表上启用可搜索字段,并将搜索类别设置为BAccount。搜索类别确定搜索结果的显示方式。
保存并编译代码。
登录到Acumatica中的Customization管理器。
找到要启用可搜索字段的数据表(MyCustomTable)并打开它。
在“Fields”选项卡上,找到要启用的可搜索字段(UsrSearchField1)并设置其“Searchable”标志为“True”。
保存并发布自定义对象。
现在,您应该能够在Acumatica中使用UsrSearchField1字段进行搜索。