【问题标题】:Acumatica refer custom field to another custom field on different screenAcumatica 将自定义字段引用到不同屏幕上的另一个自定义字段
【发布时间】:2018-03-11 15:04:52
【问题描述】:

我在客户屏幕中创建了 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);
 }
 }
}

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

【问题讨论】:

    标签: customization acumatica


    【解决方案1】:

    您应该订阅 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;
            }
        } 
    }
    

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

    下面的代码 sn-p 应该在销售订单屏幕上实现预期的结果。如果您在理解下面的代码时仍有问题,我强烈建议您参加 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;
                }
            }
        }
    }
    

    【讨论】:

    • 我无法理解这段代码以及我应该如何在我的定制中使用它。我已经编辑了问题
    • 我在自定义中使用了上面的代码,但仍然没有显示结果。我们是否必须使用 SetValue 为新字段设置值?
    • SetValue 方法与简单的属性值分配 100% 相同。您是否尝试在应用自定义后重新启动 IIS 或回收应用程序池?您的 Web 服务器上可能缓存了一些遗留扩展实例,这会阻止自定义按预期工作。如果重新启动 Web 服务器没有帮助,请尝试在 VS 中调试您的代码并验证您的 SOOrder_CustomerID_FieldUpdated 事件是否被引发并将值分配给自定义字段。
    • 我重新启动了 IIS 但仍然无法得到结果...我将尝试在 VS 中调试代码
    【解决方案2】:

    通过以下方式自定义 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>))]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-29
      相关资源
      最近更新 更多