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. HTML5 3D爱心动画 晚来的七夕礼物

    在线演示源码下载 这么好看的HTML5爱心动画,我们当然要把源代码分享给大家,下面是小编整理的源代码,主要是HTML代码和CSS代码. HTML代码: <div class=’heart3d’& ...

  2. 之前想搞一个nim但因为是自用我会持续修复完善

    异步方式的优点:客户端和服务端互相解耦,双方可以不产生依赖.缺点是:由于引入了消息中间件,在编程的时候会增加难度系数.此外,消息中间件的可靠性.容错性.健壮性往往成为这类架构的决定性因素. 幸运的是程 ...

  3. Java相关

    1.多线程实现方法? 1).继承Thread类实现多线程 2).实现Runnable接口方式实现多线程 3).使用ExecutorService.Callable.Future实现有返回结果的多线程 ...

  4. Robot Test Framework + Selenium 的几个坑

    现有的webtest是基于Robot 和 Selenium 来写的,没出问题的时候还挺好的,出了问题想debug介个麻烦啊(也可能是姿势不对), 特罗列如下,如有不对,求指正,指导. 1. RIDE ...

  5. 【IOS学习】1.IOS框架

    1.框架概述 iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa ...

  6. 使用js创建对象

    1.js创建关键字 //使用 New 关键字 function person(name,age){ this.name=name; this.age=age; } $(function(){ var ...

  7. 庞巴迪TCMS学习笔记之一(IEC 61131-3函数)

    在学习列车TCMS系统的软件逻辑图时会遇到IEC 61131-3的语言.其中通用的图形化函数总结如下.

  8. MYSQL常见语句

    SHOW INDEXES  from tablename EXPLAIN  tablename EXPLAIN SELECT *  FROM tablename

  9. Oracle Hints详解

    在向大家详细介绍Oracle Hints之前,首先让大家了解下Oracle Hints是什么,然后全面介绍Oracle Hints,希望对大家有用.基于代价的优化器是很聪明的,在绝大多数情况下它会选择 ...

  10. 微信网页授权snsapi_base、snsapi_userinfo的问题

    微信网页授权SCOPE分为snsapi_base.snsapi_userinfo,前者是用户无感知的静默授权只能拿到openid:而后者需要用户确认,能拿到更多的用户信息. 我有一个系统需要进行网页授 ...