To create new methods on a table without customize you should use the Table method extension class. This class will be compiled as an extension of the original table and the methods will be serialized to be included as part of the table methods.

First create a new class like below. Use the name pattern “YourClassName” + “_Extension“. On the example I will use the SalesLine table.

1
2
3
4
public static class MySalesLine_Extension
{
 
}

Create your method always as Public Static and the first parameter should always be the table (It’s by this parameter and the “_Extension” that the builder will understand that the class is a “method extension class”). After that you can provide your parameters as you normally do and you can use when you gonna call the method.

1
2
3
4
5
6
7
public static class MySalesLine_Extension
{
    public static void initSalesLineCustom(SalesLine _this)
    {
        _this.ReceiptDateRequested = today();
    }
}

After build your project and sync your database, this new method will be available to be used as part of the SalesLine table.

1
2
3
4
5
SalesLine salesLine;
 
select firstonly salesLine;
 
salesLine.initSalesLineCustom();

Important:

  • Display methods doesn’t work on class extension.
  • Static methods like “Find” that we used on AX2012 will be normal table methods now, so you need to declare the variable for the table and use the “find” as a normal method. Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public static class MySalesLine_Extension
{
    public static SalesLine findByRecId(SalesLine _this,
                                        RecId     _recId,
                                        boolean   _forupdate = false)
    {
        SalesLine salesLine;
 
        if (_forupdate)
        {
            salesLine.selectForUpdate(_forupdate);
        }
 
        select firstonly salesLine
                where salesLine.RecId == _recId;
 
        return salesLine;
    }
}

And use the find like on the code below:

1
2
3
SalesLine salesLine;
 
salesLine = salesLine.findByRecId(salesLineRecId);

AX7: HOW TO USE TABLE METHOD EXTENSION CLASS的更多相关文章

  1. Extension Method[下篇]

    四.Extension Method的本质 通过上面一节的介绍,我们知道了在C#中如何去定义一个Extension Method:它是定义在一个Static class中的.第一个Parameter标 ...

  2. Creating a settings table that can handle almost any type of value

    Update: Updated article here. Today I wanted to be able to have a table store any type of value as a ...

  3. BitHacks

    备份文件时看到的.我以前居然下过这东西. 2016-12-4 12:05:52更新 纯文本格式真棒.假如使用word写的我能拷过来格式还不乱?? Markdown真好. Bit Hacks By Se ...

  4. Bit Twiddling Hacks

    http://graphics.stanford.edu/~seander/bithacks.html Bit Twiddling Hacks By Sean Eron Andersonseander ...

  5. PA教材提纲 TAW12-1

    Unit1 Introduction to Object-Oriented Programming(面向对象编程介绍) 1.1 Explaining the Object-Oriented Progr ...

  6. RFC-RTSP

    Network Working Group H. Schulzrinne Request for Comments: 2326 Columbia U. Category: Standards Trac ...

  7. Dapper 的输出参数使用示范

    -- 普通SQL 示范-- Queries with output parameters. Hide Shrink Copy Code // output parameters // the para ...

  8. 自己打断点走的struts流程&拦截器工作原理

    ①. 请求发送给 StrutsPrepareAndExecuteFilter ②. StrutsPrepareAndExecuteFilter 判定该请求是否是一个 Struts2 请 求(Actio ...

  9. HEC-ResSim原文档

              HEC-ResSim Reservoir System Simulation             User's Manual       Version 3.1 May 201 ...

随机推荐

  1. 统计一下ie的一些问题(什么时候遇到什么时候更新)

    1.document.createElement问题 问题描述:在用ASP.NET的时候,通常我们需要注册脚本,通常是以这种形式发送到客户端: <script type="text/j ...

  2. 编程:使用递归方式判断某个字串是否回文(Palindrome)

    Answer: import java.util.Scanner; public class Palindrome { private static int len;//全局变量整型数据 privat ...

  3. python之列表、字典、集合

    列表 name = ["Alex","Eenglan","Eric"] print(name[0]) print(name[1]) prin ...

  4. RET2LIBC 练习(3) -- VIRTUALALLOC

    国庆假期没事做了几道pwn题练手,等有时间在贴出pwn题的分析. 利用VIRTUALALLOC的方法绕过DEP其实和之前的方法大同小异了,只是VIRTUALALLOC开辟了一段新的可执行的内存空间,然 ...

  5. Python之路,day9-Python基础

    回顾:抽象方法@staticmethod 不能访问类的任何属性@classmethod 类方法 只能访问公有属性@property 属性方法 , 把一个方法变成一个静态属性def sayhi() pa ...

  6. Oracle 11.2.0.1的一个Bug,客户端报ORA-03113: 通信通道的文件结尾

    半小时前,一个项目反馈应用系统部分功能报错,ORA-03113: 通信通道的文件结尾.好像是个常见的错误. 异常信息:ORA-03113: 通信通道的文件结尾 进程 ID: 2392 会话 ID: 2 ...

  7. Validate Disk Failover Failed

    Failed to write file data on cluster disk 0 partition 1, failure reason: The disk structure is corru ...

  8. JSP中动态include和静态include的区别(简版)

    动态的include: 用法:<jsp:include page="1.jsp" flush="true" /> 特点:行为元素,可以带参数:先编译 ...

  9. 关于MySql 关键字与字段名冲突 的问题

    我在用mysql创建数据表时,其中一个表怎么创建都提示失败,最终我把语句翻来覆去折腾了许多遍之后发现原来我的一个字段值的名称为order的字段出了问题,把它去了就好了,最后结论就是设置字段值名称时不要 ...

  10. ajax的两种方式

    get:var ajax=new XMLHttpRequest();ajax.open('get','__URL__/check_all?val='+check);ajax.send();ajax.o ...