Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an X++ batch job in Axapta 3.0?

Tags:

axapta

x++

I'd like to create a batch job in X++ for Microsoft Axapta 3.0 (Dynamics AX).

How can I create a job which executes an X++ function like this one?

static void ExternalDataRead(Args _args)
{
...
}
like image 875
Enrico Detoma Avatar asked Mar 02 '23 06:03

Enrico Detoma


1 Answers

Here's the bare minimum needed to create a batch job in AX:

Create a batch job by creating a new class that extends the RunBaseBatch class:

class MyBatchJob extends RunBaseBatch
{
}

Implement the abstract method pack():

public container pack()
{
    return connull();
}

Implement the abstract method unpack():

public boolean unpack(container packedClass)
{
    return true;
}

Override the run() method with the code you want to execute:

public void run()
{
    ;
    ...
    info("MyBatchJob completed");
}

Add a static main method to your class to create an instance of your class and call the standard RunBaseBatch dialog:

static void main(Args _args)
{
    MyBatchJob myBatchJob = new MyBatchJob();
    ;
    if(myBatchJob.prompt())
    {
        myBatchJob.run();
    }
}

If you want your batch job to have a description in the batch list, add a static description method to your class:

server client static public ClassDescription description()
{
    return "My batch job";
}
like image 68
Jay Hofacker Avatar answered Mar 31 '23 15:03

Jay Hofacker