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. 【引】objective-c,3:关于block

    原文参考博文: http://blog.devtang.com/2013/07/28/a-look-inside-blocks/ http://www.cnblogs.com/kesalin/arch ...

  2. Jenkins的配置(rpm red hat方式)

    Jenkins的配置文件位置 #### sudo chown -R admin /usr/lib/jenkins sudo chgrp -R admin /usr/lib/jenkins #### s ...

  3. Linux任务计划

    Linux任务计划: 一次性任务执行(at.batch): at:定时任务,指定一个时间执行一个任务,只能执行一次. at使用方式: 交互式:让用户在at>提示符输入多个要执行的命令: 批处理: ...

  4. C#-2 wpf 项目编程结构设计

    View:界面布局 EXCEL ViewModel:流程,数据粘合胶水 Model: 1)DB 结构 (数据库结构) 2)绑定的数据(界面交互数据) Service:1)BLL(画流程图)画业务逻辑图 ...

  5. 开机自动执行脚本 与 update-rc.d

    http://coderbee.net/index.php/linux/20130524/141 update-rc.d    script_name defaultsupdate-rc.d    s ...

  6. ASP.NET MVC图片上传

    工具:ssi-uploader $('#id').ssi_uploader({ url: 'path' }); public ActionResult path() { HttpPostedFileB ...

  7. cookie 和session 的区别:

    1.cookie数据存放在客户的浏览器上,session数据放在服务器上.2.cookie不是很安全,别人可以分析存放在本地的COOKIE并进行COOKIE欺骗 考虑到安全应当使用session.3. ...

  8. [2016.01.01]万峰文本处理专家 v2.0

    <万峰文本处理专家>是一款简单易用,且功能强大的各类文本文件处理软件.1.支持多任务的处理模式,允许一次处理多个任务.2.支持正则表达式替换,替换更加强大:3.支持各类关键字的行处理操作: ...

  9. 学习笔记之vector向量容器

    今天复习到vector向量容器,里面包括vector向量容器的一些优点以及具体的使用方法及代码,分享给大家. Vector向量容器不但能够像数组一样对元素进行随机访问,还可以在尾部插入元素,是一种简单 ...

  10. 百度地图api2.0体验

    前言:这两天在做百度地图的功能,查看了百度官网的api完成了基本功能 api地址http://developer.baidu.com/map/jshome.htm 注意是javascript API ...