如何在 Acumatica C# 中访问自定义字段 [英] How do I access custom fields in Acumatica C#

查看:21
本文介绍了如何在 Acumatica C# 中访问自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新 GLTran 中的自定义字段.在帐户详细信息屏幕上,我有一个按钮,单击该按钮后,应为每个选定的交易更新自定义字段.我无法访问自定义字段以更新它.这是我最近的代码迭代:

I'm attempting to update a custom field in GLTran. On the Account Details screen I have a button that, when clicked, should update a custom field for each selected transaction. I am unable to access the custom field in order to update it. Here's my most recent iteration of my code:

public class AccountByPeriodEnq_Extension:PXGraphExtension<AccountByPeriodEnq>
{
    public PXAction<AccountByPeriodFilter> recon;

    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Reconcile")]
    protected void Recon()
    {
        PXCache gltran = Base.Caches[typeof(GLTran)];
        foreach (GLTran tran in gltran.Updated)
        {
            var GLTranEx = tran.GetExtension<GLTranExt>(); 
            //                                 ^^^^
            //This is giving "The type or namespace name "GLTranExt" could not be found

            GLTranEx.UsrRecon = true;                
        }
    }
}

请放轻松,因为这是我第一次尝试 Acumatica 定制.

Please go easy on me as this is my first attempt at Acumatica customization.

推荐答案

乍一看,似乎无法从 AccountByPeriodEnq_Extension 类型的命名空间访问 GLTranExt 类型的命名空间.您可以将两种类型放在同一个命名空间中,也可以使用using"指令来声明命名空间.

At first glance it looks like the namespace of type GLTranExt is not accessible from the namespace of type AccountByPeriodEnq_Extension. You could put both types in the same namespace or with 'using' directive you could declare the namespace.

再看一遍,我在您使用的某些地方看到的可能是您的命名不匹配:

On second look, it could be that you have some naming mismatch as I see in some place you use:

GLTranEx

在其他方面:

GLTranExt

使用自定义项目编辑器时,您可以使用 VIEW SOURCE 按钮检查 DAC 扩展的命名空间:

When using Customization Project Editor you can check the namespace of the DAC extension with VIEW SOURCE button:

如果您将 DAC 扩展作为代码文件,命名空间在源代码中:

If you have the DAC extension as a code file, namespace is in the source code:

namespace PX.Objects.GL
{
  public class GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
  {
  }
}

正如你所看到的,GLTran 的默认扩展名进入了命名空间 PX.Objects.GL在您的代码中,我希望在该命名空间上有一个使用"指令:

As you can see by default extension of GLTran goes into namespace PX.Objects.GL In your code, I would expect a 'using' directive on that namespace:

using PX.Objects.GL;

public class AccountByPeriodEnq_Extension:PXGraphExtension<AccountByPeriodEnq>
{
}

或者在类型上加上命名空间前缀:

Or put the namespace prefix on the type:

PX.Objects.GL.GLTranExt GLTranEx = tran.GetExtension<PX.Objects.GL.GLTranExt>(); 

这篇关于如何在 Acumatica C# 中访问自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆