当用户将PO和PO来源的特定项目标记为Dropship时,我需要将自定义字段从SO屏幕填充到PO屏幕。当用户在“销售订单”屏幕上的“操作”菜单中创建采购订单时。
我已经在PO屏幕POOrderEntryExtension上的自定义字段FieldUpdated事件中编写了代码,但是当我尝试使用BQL从SO屏幕获取自定义字段值时它没有显示SO OrderNbr,如下所示 -
protected virtual void POOrder_CustomField_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (POOrder)e.Row;
if (row != null && !string.IsNullOrEmpty(row.SOOrderNbr) && row.OrderType == POOrderType.DropShip)
{
SOOrder order = PXSelectJoin<SOOrder,
LeftJoin<SOLine,
On<SOOrder.orderType, Equal<SOLine.orderType>,
And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>>,
Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>,
And<SOLine.pOSource, Equal<Required<SOLine.pOSource>>>>>>.Select(new PXGraph(), row.SOOrderType, row.SOOrderNbr, "D");
if (order != null)
{
e.NewValue = order.CustomFieldFromSO;
}
}
}
&#13;
因此我在POOrder_RowPersisting事件中编写了相同的代码,但现在每次保存采购订单时,即使我修改,它也会覆盖SalesOrder中的值。
有什么建议吗?
答案 0 :(得分:0)
由于您尝试将值默认值设置为来自SOOrder并且SOOrderNbr字段仅在创建采购订单时更新一次,而不是检查每个持久性的分配,您可以使用完成相同的目标POOrder_SOOrderNbr_FieldUpdated 事件。下面是在“创建采购订单操作”中从SOOrder到POOrder的单个自定义字段的示例代码,您可以根据需要向SOOrder选择添加其他过滤。
public class SOOrderExtension : PXCacheExtension<SOOrder>
{
#region CustomField
public abstract class usrCustomField
{ }
[PXDBString(60)]
[PXUIField(DisplayName = "Custom Field")]
public virtual string UsrCustomField { get; set; }
#endregion
}
public class POOrderExtension : PXCacheExtension<POOrder>
{
#region CustomField
public abstract class usrCustomField
{ }
[PXDBString(60)]
[PXUIField(DisplayName = "Custom Field")]
public virtual string UsrCustomField { get; set; }
#endregion
}
public class POOrderEntryExtension : PXGraphExtension<POOrderEntry>
{
public virtual void POOrder_SOOrderNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
POOrder row = e.Row as POOrder;
if (row != null)
{
POOrderExtension rowExt = PXCache<POOrder>.GetExtension<POOrderExtension>(row);
SOOrder order = PXSelectReadonly<SOOrder, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(this.Base, new object[] { row.SOOrderType, row.SOOrderNbr });
if(order != null)
{
SOOrderExtension orderExt = PXCache<SOOrder>.GetExtension<SOOrderExtension>(order);
rowExt.UsrCustomField = orderExt.UsrCustomField;
}
}
}
}
答案 1 :(得分:-1)
我发现,我们可以检查操作是否在POOrder_RowPersisting事件中插入并且不会覆盖这些值。下面是代码示例 -
protected virtual void POOrder_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert)
{
var row = (POOrder)e.Row;
if (row != null && !string.IsNullOrEmpty(row.SOOrderNbr) && row.OrderType == POOrderType.DropShip)
{
SOOrder order = PXSelectJoin<SOOrder,
LeftJoin<SOLine,
On<SOOrder.orderType, Equal<SOLine.orderType>,
And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>>,
Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>,
And<SOLine.pOSource, Equal<INReplenishmentSource.dropShipToOrder>>>>>.Select(new PXGraph(), row.SOOrderType, row.SOOrderNbr);
if (order != null)
{
row.CustomField = order.CustomFieldFromSO;
}
}
}
}
&#13;