AX7: HOW TO USE TABLE METHOD EXTENSION CLASS

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);

时间: 2024-10-11 03:18:06

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

Extension Method[下篇]

四.Extension Method的本质 通过上面一节的介绍,我们知道了在C#中如何去定义一个Extension Method:它是定义在一个Static class中的.第一个Parameter标记为this关键字的Static Method.在这一节中,我们来进一步认识Extension Method. 和C# 3.0的其他新特性相似,Extension Method仅仅是C#这种.NET Programming Language的新特性而已.我们知道,C#是一种典型的编译型的语言,我们编

Bit Twiddling Hacks

http://graphics.stanford.edu/~seander/bithacks.html Bit Twiddling Hacks By Sean Eron Anderson[email protected] Individually, the code snippets here are in the public domain (unless otherwise noted) — feel free to use them however you please. The aggr

cocos2d-x之TableView列表

HelloWorld.h #ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__ #include "cocos2d.h"#include <cocos-ext.h> USING_NS_CC_EXT;USING_NS_CC;//相当于using namespace cocos2d; //使类继承TableViewDataSource类型添加列表项,继承TabelViewDelegate添加事件监听器class

PA教材提纲 TAW12-1

Unit1 Introduction to Object-Oriented Programming(面向对象编程介绍) 1.1 Explaining the Object-Oriented Programming Model(解释面向对象编程) 编程语言发展史: 最早的语言是面向过程语言( procedural programming ): COBOL 差不多同时出现了面向对象( object-oriented programming )和面向逻辑与过程( logical and procedu

RTSP Spectification

Refer: https://www.ietf.org/rfc/rfc2326.txt Network Working Group H. SchulzrinneRequest for Comments: 2326 Columbia U.Category: Standards Track A. Rao Netscape R. Lanphier RealNetworks April 1998 Real Time Streaming Protocol (RTSP) Status of this Mem

CRC32 of Ether FCS with STM32

Everyone knows that STM32F1xx, STM32F2xx, STM32F4xx have a hardware unit with a polynomial CRC32 0x04C11DB7. And he, in general, work. But only a checksum for some reason does not coincide with that calculated softvarno. The Google usually 2 types of

Cocos2d-x滚动列表具体解释(CCScrollView的使用)

今天要写一个滚动列表功能,类似以下这样.(图片资源都是自己从天天酷跑里面抠的,仅用于学习方便) 首先,这样一个列表就和iOS里面的UITableView没什么两样,当然,Android中肯定也存在类似的控件. 在cocos2d-x引擎中參照ios中的UITableView实现了一个叫做CCTableView的类,用于创建列表,对于熟悉ios程序设计的人来说,这个内容应该是非常好理解的. 以下就介绍下CCTableView. 首先,mark几个比較好的博文. Cocos2d-x CCTableVi

CRC32 Source Code

/* The Quest Operating System * Copyright (C) 2005-2010 Richard West, Boston University * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Softwar

ItextDemo&lt;二&gt;

Nested tables TableTemplate.java /** * Example written by Bruno Lowagie in answer to the following question: * http://stackoverflow.com/questions/22093993/itext-whats-an-easy-to-print-first-right-then-down */ package sandbox.tables;   import com.itex