Search code examples
batch-processingaxaptamicrosoft-dynamicsx++dynamics-ax-2012

How to get by code the BatchJob Recid in job process?


I have a custom class extends RunbaseBatch. In run method I want to get the BatchJob RecId. I try to use these code line:

this.batchInfo().parmBatch();
// or 
this.batchInfo().parmBatch().BatchJobId;

But in both case the methods retrieves a null value. Is there any way to get this information? Where can I take this data?


Solution

  • Have a look at the static method BatchHeader::getCurrentBatchHeader (MSDN)

    It returns an object of class BatchHeader with a property parmBatchHeaderId which should contain your desired information.