如何在Acumatica

时间:2017-02-14 19:14:53

标签: acumatica

我需要在表APPayment中添加一个bool字段。因为APPayment是从APRegister继承的,所以我按以下方式扩展到类APRegister:

public class APRegisterExt: PXCacheExtension<APRegister>
{

    #region UsrPOAllocated
    public abstract class usrPOAllocated : IBqlField
    {
    }

    [PXDBBool]
    [PXUIField(DisplayName = "Allocated")]
    public bool? UsrPOAllocated{ get; set; }

    #endregion
}

但是当我导航到页面AP301000,AP302000时,我看到以下错误:

无效的列名称&#39; UsrPOAllocated&#39;。

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Data.SqlClient.SqlException:列名无效&#39; UsrPOAllocated&#39;。

来源错误:

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

堆栈追踪:

[SqlException(0x80131904):列名无效&#39; UsrPOAllocated&#39;。]    PX.Data.PXSqlDatabaseProvider.a(SqlException A_0,IDbCommand A_1)+765    PX.Data.PXSqlDatabaseProvider.ExecuteReaderInternal(IDbCommand命令,CommandBehavior行为)+357    PX.Data.PXSelectResultEnumerator.System.Collections.IEnumerator.MoveNext()+ 473    PX.Data.PXView.GetResult(Object []参数,PXFilterRow []过滤器,布尔reverseOrder,Int32 topCount,PXSearchColumn []排序,布尔&amp; overrideSort,布尔&amp; extFilter)+6089    PX.Data.PXView.Select(Object [] currents,Object []参数,Object []搜索,String [] sortcolumns,Boolean [] descendings,PXFilterRow []过滤器,Int32&amp; startRow,Int32 maximumRows,Int32&amp; totalRows)+ 2651    PX.Data.PXGraph.ExecuteSelect(String viewName,Object []参数,Object []搜索,String [] sortcolumns,Boolean [] descendings,PXFilterRow []过滤器,Int32&amp; startRow,Int32 maximumRows,Int32&amp; totalRows)+1220    PX.Web.UI.PXBaseDataSource.a(Object [] A_0,Object [] A_1,String [] A_2,Boolean [] A_3,PXFilterRow [] A_4,DataSourceSelectArguments A_5)+218    PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName,DataSourceSelectArguments arguments,PXDSSelectArguments pxarguments)+13726    PX.Web.UI.PXDataSource.ExecuteSelect(String viewName,DataSourceSelectArguments arguments,PXDSSelectArguments pxarguments)+149    PX.Web.UI.PXDataSourceView.Select(DataSourceSelectArguments参数,PXDSSelectArguments swarguments,DataSourceViewSelectCallback回调)+65    PX.Web.UI.PXFormDataProvider.DataBind()+383    PX.Web.UI.PXBoundPanel.PerformSelect()+135    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()+139    PX.Web.UI.PXDataViewBar.OnPreRender(EventArgs e)+33    System.Web.UI.Control.PreRenderRecursiveInternal()+110    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Control.PreRenderRecursiveInternal()+ 207    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+2994

所以问题是,如何在Acumatica中正确扩展类,这些类是其他实体的基类并实现其他接口? 还有一个问题。如果我扩展基类APRegister,那么如何在网格附加字段中引用可能编辑?我的意思是如果我扩展APRegister但需要在网格中显示APPayment元素,那么如何用编辑选项显示它们呢?

1 个答案:

答案 0 :(得分:1)

一旦为APRegister数据库表添加了UsrPOAllocated列,提供的代码片段在全新的Acumatica网站上似乎完全正常:

public class APRegisterExt : PXCacheExtension<APRegister>
{
    #region UsrPOAllocated
    public abstract class usrPOAllocated : IBqlField
    {
    }

    [PXDBBool]
    [PXUIField(DisplayName = "Allocated")]
    public bool? UsrPOAllocated { get; set; }

    #endregion
}

enter image description here

由于APInvoice是从APRegister继承的,因此对于APInvoice DAC的每个实例,框架将始终初始化为基本APRegister DAC声明的所有扩展。

以下是一个小样本,展示了如何访问在针对APInvoice DAC引发的RowSelected事件处理程序中的APRegister DAC扩展中声明的UsrPOAllocated字段:

public class APInvoiceEntryExt : PXGraphExtension<APInvoiceEntry>
{
    public void APInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        APInvoice invoice = e.Row as APInvoice;
        if (invoice == null) return;

        var invoiceExt = invoice.GetExtension<APRegisterExt>();
        if (invoiceExt.UsrPOAllocated != true)
        {
            sender.RaiseExceptionHandling<APInvoice.refNbr>(invoice, invoice.RefNbr,
                new PXSetPropertyException("Document is not allocated", PXErrorLevel.Warning));
        }
        else
        {
            sender.RaiseExceptionHandling<APInvoice.refNbr>(invoice, invoice.RefNbr, null);
        }
    }
}

上面的自定义是使用布局编辑器创建的: enter image description here

这是Aspx,该布局编辑器生成: <px:PXCheckBox runat="server" ID="CstPXCheckBox1" DataField="UsrPOAllocated" />

enter image description here