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

Acumatica 在弹出窗口中更新自定义字段,acumatica,Acumatica,我在更新弹出模型中的自定义字段时遇到问题 我在Customers页面中创建了一个customer字段“UsrCustomerNote”,它创建了以下DAC扩展 namespace PX.Objects.CR { public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount> { #region UsrCustomerNote [PXDBString(1000)]

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

我在Customers页面中创建了一个customer字段“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
    }
}
名称空间PX.Objects.CR
{
公共类BAccountExt:PXCacheExtension
{
#区域UsrCustomerNote
[PXDBString(1000)]
[PXUIField(DisplayName=“客户注释”)]
公共虚拟字符串UsrCustomerNote{get;set;}
公共抽象类usrCustomerNote:IBqlField{}
#端区
}
}
我在客户页面中添加了字段控件,如下所示

我的要求是在选择客户时,在“服务订单”页面的新弹出对话框中显示此CustomerNote字段值

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

public PXFilter<BAccount> CustomerSelector;
公共PXFilter CustomerSelector;
所以,我在服务订单页面中添加了一个弹出面板。并在弹出窗口中添加了自定义字段。

然后,我在服务订单页面中为字段CustomerID添加了一个字段\更新的事件处理程序。下面是ServiceOrderEntry图形扩展的完整代码片段

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
  }
}
使用系统;
使用PX.Objects;
使用PX数据;
使用PX.Objects.AR;
使用PX.Objects.CR;
命名空间PX.Objects.FS
{
公共类ServiceOrderEntry_扩展:pxGrapherExtension
{
#区域事件处理程序
公共PXFilter CustomerSelector;
受保护的无效FSServiceOrder_CustomerID_FieldUpdate(PXCache缓存、PXFieldUpdatedEventArgs e、PXFieldUpdatedInvokeBaseHandler)
{
if(InvokeBaseHandler!=null)
InvokeBaseHandler(缓存,e);
var row=(FSServiceOrder)e.row;
如果(客户选择AskExt(委托
{
BAccountEnq BAccountEnq=PXGraph.CreateInstance();
BAccount BAccount=PXSelect.Select(bAccountEnq,row.CustomerID);
CustomerSelector.Current=bAccount;
CustomerSelector.Current.GetExtension().UsrCustomerNote=(字符串)bAccount.GetExtension().UsrCustomerNote;
/*
*下面的那个也不行
*/
//CustomerSelector.Cache.SetValue(CustomerSelector.Current,(string)bAccount.GetExtension().UsrCustomerNote);
CustomerSelector.Update(CustomerSelector.Current);
})==WebDialogResult.OK)
{
//用于更新“客户”页面中的值的代码
}
}
#端区
}
}
它加载弹出面板,但文本字段为空,即使我可以看到该字段的值已在调试模式下更新。


我需要帮助来找出我缺少的内容。

我建议将Where条件添加到过滤器视图中,而不是在初始化委托中设置current:

public PXFilter<BAccount,Where<BAccount.bAccountID,Equal<Current<FSServiceOrder.customerID>>>> CustomerSelector;
公共PXFilter 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();
}
if(CustomerSelector.AskExt(true)=WebDialogResult.OK)
{
CustomerMaint CustomerMaint=PXGraph.CreateInstance();
var updatedValue=PXCache.GetExtension(CustomerSelector.Current);
Customer=customersMaint.BAccount.Search(CustomerSelector.Current.bAccountID);
var valueToUpdate=PXCache.GetExtension(CustomerSelector.Current);
valueToUpdate.UsrCustomerNote=updatedValue.UsrCustomerNote;
CustomerMaint.BAccount.Update(客户);
CustomerMaint.Save.PressButton();
}

我还没有测试这段代码

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

PXFilter只将Table作为参数,因为它只有一条记录,所以代码只能是这样,不能添加Where子句<代码>PXFilter CustomerHelper我甚至添加了一个定制的DAC来简化这个
系统;使用PX数据;命名空间CustomerNote{[Serializable]公共类CustomerNoteDAC:IBqlTable{[PXDBString(4000)][PXUIField(DisplayName=“Notes”)]公共虚拟字符串UsrCustomerNote{get;set;}公共抽象类UsrCustomerNote:IBqlField{}}
公共PXFilter CustomerSelector;受保护的无效FSServiceOrder_CustomerID_FieldUpdated(PXCache缓存,PXFieldUpdatedEventArgs e,PXFieldUpdated InvokeBaseHandler){if(InvokeBaseHandler!=null)InvokeBaseHandler(缓存,e);var row=(FSServiceOrder)e.row;BAccountEnq BAccountEnq=PXGraph.CreateInstance();BAccount BAccount=PXSelect.Select(bAccountEnq,row.CustomerID);
CustomerSelector.Current.UsrCustomerNote=(字符串)BAccount.GetExtension().UsrCustomerNote;CustomerSelector.Update(CustomerSelector.Current);if(CustomerSelector.AskExt(true)==WebDialogResult.OK){}
@BikashLama您仍然无法更新该字段吗?从您的评论中,我不明白现在的问题是什么。是的,该字段仍然没有更新。我甚至将对话框的自动加载事件更改为“True”,但这也不起作用。