将备用ID字段添加到SOLine网格上的库存ID选择器

时间:2016-11-03 12:58:33

标签: acumatica

我正在尝试将Alternate ID字段添加到SOLine详细信息网格上的搜索选择器中。我的代码如下:

    [PXNonInstantiatedExtension]
public class SO_SOLine_ExistingColumn : PXCacheExtension<PX.Objects.SO.SOLine>
{
  #region InventoryID
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXSelector(typeof(Search2<InventoryItem.inventoryCD, LeftJoin<INItemXRef, On<InventoryItem.inventoryID, Equal<INItemXRef.inventoryID>>>>),

        typeof(PX.Objects.IN.InventoryItem.inventoryCD),
        typeof(PX.Objects.IN.INItemXRef.alternateID),
        typeof(PX.Objects.IN.InventoryItem.descr),
        typeof(PX.Objects.IN.InventoryItem.itemClassID),
        typeof(PX.Objects.IN.InventoryItem.itemStatus),
        typeof(PX.Objects.IN.InventoryItem.itemType),
        typeof(PX.Objects.IN.InventoryItem.baseUnit),
        typeof(PX.Objects.IN.InventoryItem.salesUnit),
        typeof(PX.Objects.IN.InventoryItem.purchaseUnit),
        typeof(PX.Objects.IN.InventoryItem.basePrice))]
   public int? InventoryID { get; set; }
    #endregion
}
     public void SOLine_InventoryID_CacheAttached(PXCache sender)
{
}

这会将Alternate ID字段添加到选择器中,并且可能会暂时,在选择时返回正确的Inventory CD,但随后Inventory CD会更改整数ID,这当然会引发错误指示,因为ID是不承认。

2 个答案:

答案 0 :(得分:0)

您需要让您的Selector Search for InventoryID,然后添加&#34; SubstituteKey&#34;将在选择器的UI中显示InventoryCD的选项。示例:[PXSelector(typeof(InventoryItem.inventoryID),SubstituteKey = typeof(InventoryItem.inventoryCD))]

答案 1 :(得分:0)

George,在InventoryItem和INItemXRef DAC之间存在一对多的关系 - 将PX.Objects.IN.INItemXRef.alternateID BQL字段添加到PXSelectorAttribute的声明中是不足以完成任务的。

  1. 为InventoryItem DAC声明未绑定的文本字段,以存储每个库存项目的备用ID:

    public class InventoryItemExt : PXCacheExtension<InventoryItem>
    {
        #region AlternateIDs
        public abstract class alternateIDs : IBqlField { }
    
        [PXString]
        [PXUIField(DisplayName = "Alternate IDs")]
        public virtual string AlternateIDs { get; set; }
        #endregion
    }
    
  2. 在SOOrderEntry BLC扩展中订阅RowSelecting事件(强制使用PXConnectionScope与数据库建立另一个连接),以连接每一行的备用ID,并使用计算的字符串值填充未绑定的AlternateIDs字段:

    public class SOOrderEntryExtension : PXGraphExtension<SOOrderEntry>
    {
        public override void Initialize()
        {
            Base.RowSelecting.AddHandler<InventoryItem>((sender, e) =>
            {
                InventoryItem item = e.Row as InventoryItem;
                if (item == null) return;
    
                string alternateIDs = string.Empty;
                using (new PXConnectionScope())
                {
                    foreach (INItemXRef crossRef in PXSelect<INItemXRef,
                        Where<INItemXRef.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, item.InventoryID))
                    {
                        alternateIDs = string.IsNullOrEmpty(alternateIDs) ?
                            crossRef.AlternateID : alternateIDs + "; " + crossRef.AlternateID;
                    }
                }
                item.GetExtension<InventoryItemExt>().AlternateIDs = alternateIDs;
            });
        }
    }
    
  3. 启动销售订单屏幕的布局编辑器(SO301000),然后从“操作”菜单中选择“编辑Aspx”选项: enter image description here

  4. 在Aspx文件中找到InventoryID选择器的声明:

    <px:PXSegmentMask CommitChanges=“True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" />
    
  5. 对于InventoryID选择器,将FastFilterFields属性设置为AlternateIDs并通过声明AlternateIDs列附加列,然后单击Generate Customization script:

    <px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
        <GridProperties FastFilterFields="AlternateIDs">
            <Columns>
                <px:PXGridColumn DataField="AlternateIDs" AutoGenerateOption="Add" Width="250px" />
            </Columns>
        </GridProperties>
    </px:PXSegmentMask>