首页 文章

在弹出窗口上更新自定义字段

提问于
浏览
0

我在更新弹出模型中的自定义字段时遇到问题 .

我在Customers页面中创建了一个客户字段'UsrCustomerNote',它创建了以下DAC扩展 .

namespace PX.Objects.CR
{
    public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
    {
        #region UsrCustomerNote
        [PXDBString(1000)]
        [PXUIField(DisplayName="Customer Note")]
        public virtual string UsrCustomerNote { get; set; }
        public abstract class usrCustomerNote : IBqlField { }
        #endregion
    }
}

我在这样的客户页面中添加了字段控制 .

enter image description here

我的要求是在选择Customer时在Service Orders页面的新弹出对话框中显示此CustomerNote字段值 .

首先,我在名为“ServiceOrderEntry”的服务订单的图形扩展中创建了一个视图名称CustomerSelector .

public PXFilter<BAccount> CustomerSelector;

所以,我在Service Order页面添加了一个Popup Panel . 并在弹出窗口中添加了自定义字段 .
enter image description here

然后,我在Service Orders页面中为字段CustomerID添加了Field_Updated事件处理程序 . 这是ServiceOrderEntry Graph扩展的完整代码片段 .

using System;
using PX.Objects;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;

namespace PX.Objects.FS
{
  public class ServiceOrderEntry_Extension : PXGraphExtension<ServiceOrderEntry>
  {
        #region Event Handlers
        public PXFilter<BAccount> CustomerSelector;

        protected void FSServiceOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (FSServiceOrder)e.Row;
            if (CustomerSelector.AskExt(delegate
            {
                BAccountEnq bAccountEnq = PXGraph.CreateInstance<BAccountEnq>();
                BAccount bAccount = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(bAccountEnq, row.CustomerID);
                CustomerSelector.Current = bAccount;
                CustomerSelector.Current.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote = (string)bAccount.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote;
                /*
                 * The below one didn't work too
                 */
                //CustomerSelector.Cache.SetValue<PX.Objects.CR.BAccountExt.usrCustomerNote>(CustomerSelector.Current, (string)bAccount.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote);
                CustomerSelector.Update(CustomerSelector.Current);

            }) == WebDialogResult.OK)
            {
                //CODE TO UPDATE THE VALUE IN CUSTOMERS PAGE
            }
        }
        #endregion
  }
}

它加载弹出面板但TextField为空,即使我可以看到该字段的值已在调试模式下更新 .
enter image description here

我需要帮助才能找到我所缺少的东西 .

2 回答

  • 0

    我建议将Where条件添加到Filter View,而不是在Initialization Delegate中设置current:

    public PXFilter<BAccount,Where<BAccount.bAccountID,Equal<Current<FSServiceOrder.customerID>>>> CustomerSelector;
    

    您还需要更新客户维护中的值并保存 . 以下是如何做到这一点的示例 .

    if (CustomerSelector.AskExt(true) == WebDialogResult.OK)
    {
        CustomerMaint customersMaint = PXGraph.CreateInstance<CustomerMaint>();
        var updatedValue = PXCache<BAccount>.GetExtension<BAccountExt>(CustomerSelector.Current);
        Customer customer = customersMaint.BAccount.Search<Customer.bAccountID>(CustomerSelector.Current.bAccountID);
        var valueToUpdate = PXCache<BAccount>.GetExtension<BAccountExt>(CustomerSelector.Current);
        valueToUpdate.UsrCustomerNote = updatedValue.UsrCustomerNote;
        customersMaint.BAccount.Update(customer);
        customersMaint.Save.PressButton();
    }
    

    我还没有测试过这段代码 .

  • 1

    我解决了这个问题 . 对于Dialog,需要将LoadOnDemand属性设置为true . 代码从一开始就很好 . 感谢@Samvel Petrosov对此的帮助 .

相关问题