首页 > 解决方案 > 通用属性搜索

问题描述

我正在尝试搜索存储在我的属性下的值。

例如,我在“案例”屏幕下有一些属性。我想从通用搜索中搜索这些属性的值。因此,当我进行通用搜索时,它会提出这种情况。

我知道我们可以包含PXSearchable在注释中。但是由于属性存储在 CSAnswers 表中,我不确定如何包含它。此外,CSAnswers 不可用于重建索引屏幕 (SM209500)

我有下面的代码,它不工作。

public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
{
  #region PXNotes
  [PXNote()]
  [PXSearchable(SM.SearchCategory.CR, "{0}", new Type[] { typeof(CRCase.caseCD) }, new Type[] { typeof(CSAnswers.value) },
   Line1Format = "{0}{1}", Line1Fields = new Type[] { typeof(CRCase.caseCD),typeof(CRCase.subject) }
  )]
  public Guid? NoteID { get; set; }
  #endregion
}

在此处输入图像描述

任何建议。

标签: acumatica

解决方案


我在 InventoryItem 上使用 DAC 扩展中的未绑定字段执行此操作,以应用 PXDBScalar 来检索值,然后将该字段合并到 [PXNote] 中。PXDBScalar 允许您根据当前 DAC 中的某个值从另一个 DAC 中查找一个值。我对此有点挣扎,因为我想在 Where 子句中使用 Current,但在这种情况下不使用 Current<>。此示例中的 PXDBScalar 将为我的 InventoryItem 查找我的 AttributeID“SITEM”的 CSAnswer 属性值。

为了获取特定的 AttributeID,我定义了一个带有特定 AttributeID 的 PX.Data.BQL.BqlString.Constant 以供 PXDBScalar 引用,因为它在使用 PXDBScalar 时需要一个类型。

public sealed class InventoryItemExt : PXCacheExtension<PX.Objects.IN.InventoryItem>
{
    #region SItem
    [PXString]
    [PXUIField(DisplayName = "S Item")]
    [PXDBScalar(typeof(Search<CSAnswers.value,
        Where<CSAnswers.refNoteID, Equal<InventoryItem.noteID>,
        And<CSAnswers.attributeID, Equal<AttribSItem>>>>))]
    public string SItem { get; set; }
    public abstract class sItem : PX.Data.BQL.BqlString.Field<sItem> { }
    #endregion

    public class AttribSItem : PX.Data.BQL.BqlString.Constant<AttribSItem>
    {
        public AttribSItem() : base("SITEM") { }
    }
}

在 NoteID 的 PXSearchable 属性中,我添加了对上面我的 PXString 字段的引用。

#region NoteID  
[PXSearchable(SearchCategory.IN, "{0}: {1}",
    new Type[] { typeof(InventoryItem.itemType), typeof(InventoryItem.inventoryCD) },
    new Type[] { typeof(InventoryItem.descr), typeof(InventoryItem.body), typeof(InventoryItemExt.sItem) },
    NumberFields = new Type[] { typeof(InventoryItem.inventoryCD) },
    Line1Format = "{0}{1}", Line1Fields = new Type[] { typeof(INItemClass.itemClassCD), typeof(InventoryItem.baseUnit) },
    Line2Format = "{0} {1}", Line2Fields = new Type[] { typeof(InventoryItem.descr), typeof(InventoryItemExt.sItem) },
    WhereConstraint = typeof(Where<Current<InventoryItem.itemStatus>, NotEqual<InventoryItemStatus.unknown>>)
    )]
[PXNote]
public Guid? NoteID { get; set; }
#endregion

属性的通用搜索


推荐阅读