Acumatica将自定义字段引用到不同屏幕上的另一个自定义字段

时间:2017-09-29 16:41:37

标签: customization acumatica

我已在客户屏幕中创建了2个自定义字段(UsrFFA和UsrFreeFreightDay),如下所示。Customers Screen

然后我在销售订单屏幕上创建了类似字段,如下所示 Sales Order

我希望“销售订单”屏幕上的这些字段填充相应客户ID的值。

我浏览了培训材料T200并找到了这段代码

 protected void SOOrder_CustomerID_FieldUpdated(PXCache sender,PXFieldUpdatedEventArgs e)
{
 SOOrder order = e.Row as SOOrder;
 BAccount customer =
 PXSelectorAttribute.Select<SOOrder.customerID>(sender, order)
 as BAccount;
 if (customer != null)
 {
 Contact defContact = PXSelect<Contact,
 Where<Contact.bAccountID, Equal<Required<Contact.bAccountID>>,
 And<Contact.contactID, Equal<Required<Contact.contactID>>>>>
 .Select(Base, customer.BAccountID, customer.DefContactID);
 if (defContact != null)
 {
 ContactExt contactExt = PXCache<Contact>
 .GetExtension<ContactExt>(defContact);
 sender.SetValue<SOOrderExt.usrCRVerified>(order,
 contactExt.UsrCreditRecordVerified);
 }
 }
}

我无法理解此代码,我应该如何在自定义中使用它。

2 个答案:

答案 0 :(得分:0)

您应订阅SOOrder.CustomerID字段的FieldUpdated处理程序,并在“销售订单”屏幕上填写自定义字段,方法与示例5.2:插入默认明细数据记录中所示的方式相同T200培训班:

protected virtual void ShipmentLine_ProductID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
    // Obtain the new data record that contains the updated
    // values of all data fields
    ShipmentLine line = (ShipmentLine)e.Row;
    line.Description = string.Empty;
    if (line.ProductID != null)
    {
        Product product = PXSelectorAttribute.Select<ShipmentLine.productID>(sender, line) as Product;
        if (product != null)
        {
            // Copy the product name to the description of the shipment line
            line.Description = product.ProductName;
        }
    } 
}

您还可以检查步骤3.1:添加FieldUpdated事件处理程序(CustomerMaint)步骤5.2:从T300自定义销售订单表单的业务逻辑(SOOrderEntry)其他样本的培训班。

下面的代码段应在“销售订单”屏幕上完成所需的结果。如果您仍然无法理解下面的代码,我强烈建议您通过T300培训课程进行非常详细的动手练习,并逐步说明。

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public void SOOrder_CustomerID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
    {
        var order = e.Row as SOOrder;
        if (order.CustomerID != null)
        {
            var customer = PXSelectorAttribute.Select<SOOrder.customerID>(sender, order) as BAccountR;
            if (customer != null)
            {
                var customerExt = customer.GetExtension<BAccountExt>();
                var orderExt = order.GetExtension<SOOrderExt>();
                orderExt.UsrFFA = customerExt.UsrFFA;
                orderExt.UsrFreeFreightDay = customerExt.UsrFreeFreightDay;
            }
        }
    }
}

答案 1 :(得分:0)

按以下方式自定义SOOrder字段上的属性:

对于UsrFFA字段

[PXDBString(100)]
[PXUIField(DisplayName="FFA", Visible = true, Enabled = false)]
[PXFormula(typeof(Selector<SOOrder.customerID, BAccountExt.usrFFA>))]

对于UsrFreeFreightDay字段

[PXDBString(100)]
[PXUIField(DisplayName="Free Freight Day", Visible = true, Enabled = false)]
[PXFormula(typeof(Selector<SOOrder.customerID, BAccountExt.usrFreeFreightDay>))]