Thursday, 12 May 2011

Send/add batch job through code on Dynamics AX

To add job into 'Batch job' using X++ code, just skip the .prompt() method.
All you need is:
- A class that extends RunBaseBatch
- A method that add the job into batch job

Eg.

classdeclaration SendBatchJob extends RunBaseBatch
{
    ....
    ....
}

//The method that calls to add the job
static void addBatchJob()
{
    SendBatchJob    sendBatch;
    ;

    sendBatch = new SendBatchJob();
    sendBatch.sendToBatch();
}

//The method that actually add the job into 'Batch job'
void sendToBatch()
{
    this.batchInfo(); //Initialize
    batchInfo.parmBatchExecute(NoYes::Yes);
    batchInfo.doBatch();
}

No comments:

Post a Comment