我创建了一个选择器控件,它显示 INItemLotSerial 表中所有序列号的列表,并且它工作正常。问题是描述字段显示InventoryID,如何显示InventoryCD。这是我的示例代码:
[PXSelector(typeof(Search<INItemLotSerial.lotSerialNbr>),
new Type[] { typeof(INItemLotSerial.lotSerialNbr), typeof(INItemLotSerial.inventoryID) },
SubstituteKey = typeof(INItemLotSerial.lotSerialNbr), DescriptionField = typeof(INItemLotSerial.inventoryID))]
我也加入了 InventoryItem,但这不起作用。
[PXSelector(typeof(Search2<INItemLotSerial.lotSerialNbr,
LeftJoinSingleTable<InventoryItem, On<InventoryItem.inventoryID,Equal<INItemLotSerial.inventoryID>>>>),
new Type[] { typeof(INItemLotSerial.lotSerialNbr), typeof(INItemLotSerial.inventoryID) },
SubstituteKey = typeof(INItemLotSerial.lotSerialNbr), DescriptionField = typeof(InventoryItem.inventoryCD))]
最佳答案
DescriptionField
属性的主要问题是它正在等待从写入 Selector
的同一个表中获取字段。但在ID/CD的情况下,通常除了主表之外,ID所在的表中不存在CD。
已更新我删除了以前的代码(使用自定义属性和 FieldSelecting 事件处理程序实现),因为它带来了性能问题。下面的代码产生相同的查找,但通过一个内部联接获取数据,而不是前面的代码正在执行的所有请求。
您可以执行以下操作来获取此查找及其说明:
在
INItemLotSerial
和InventoryItem
表上创建PXProjection
,如下所示:[PXCacheName("Lot Serials with Inventory CD")] [PXProjection(typeof(Select2<INItemLotSerial, InnerJoin<InventoryItem, On<INItemLotSerial.inventoryID, Equal<InventoryItem.inventoryID>>>>))] public class INItemLotSerialWithInventoryItem : IBqlTable { [PXDBInt(BqlField = typeof(INItemLotSerial.inventoryID))] [PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.Visible, Visible = false)] public virtual int? InventoryID { get; set; } public abstract class inventoryID : IBqlField { } [PXDBString(InputMask = "", IsUnicode = true, BqlField = typeof(InventoryItem.inventoryCD))] [PXUIField(DisplayName = "Inventory ID")] public virtual string InventoryCD { get; set; } public abstract class inventoryCD : IBqlField { } [PXDBString(InputMask = "", IsUnicode = true, BqlField = typeof(INItemLotSerial.lotSerialNbr))] [PXUIField(DisplayName = "Lot/Serial Nbr")] public virtual string LotSerialNbr { get; set; } public abstract class lotSerialNbr : IBqlField { } }
设置您的选择器以使用此
PXProjection
,如下所示:[PXSelector(typeof(Search<INItemLotSerialWithInventoryItem.lotSerialNbr>), new Type[] { typeof(INItemLotSerialWithInventoryItem.lotSerialNbr) }, SubstituteKey = typeof(INItemLotSerialWithInventoryItem.lotSerialNbr), DescriptionField = typeof(INItemLotSerialWithInventoryItem.inventoryCD))]
关于acumatica - 选择器控件显示错误的列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56977665/