axaptadynamics-ax-2012-r2

What are the possible values and text description for batch job status in AX 2012?


I'm creating a report to show issues with batch jobs in Microsoft AX 2012, but have been unable to find anything to link the integer status values in the BATCHJOB table in SQL Server to the text description shown in the application. I was told this should exist in the model database in the enums, but I was unable to determine the proper links between the data in that database. I have also been unable to find this information in a web search or any of the documentation provided by Microsoft. Is anyone able to supply these values, or tell me where to find them?

SELECT bj.[STATUS] AS [bj_STATUS]
    -- 1: Didn't run - what else? 
    -- 2: Canceled - what else?
    -- 3: Error? 
    -- 4: Success?
    -- 5: ?
    -- 6: ?
    -- 7: ?
    -- 8: Withhold?
    -- Waiting
    -- Ended
    -- Withhold
    -- Executing
    -- Ready
    -- Finished
    -- Error
    -- Didn't run
    ,bj.[CAPTION] AS [bj_CAPTION]
    ,bjh.[STARTDATETIME] AS [bjh_STARTDATETIME]
    ,bjh.[ENDDATETIME] AS [bjh_ENDDATETIME]
    ,bjh.[BATCHCREATEDBY] AS [bjh_BATCHCREATEDBY]
    ,bjh.[CANCELEDBY] AS [bjh_CANCELEDBY]
    ,bg.[GROUP_] AS [bg_GROUP]
    ,bg.[DESCRIPTION] AS [bg_DESCRIPTION]
    ,bh.[SERVERID] AS [bh_SERVERID]
FROM [MicrosoftDynamicsAX].[dbo].[BATCHJOB] bj WITH(NOLOCK)
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHJOBHISTORY] bjh WITH(NOLOCK)
    ON bjh.[BATCHJOBID] = bj.[RECID] 
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCH] b WITH(NOLOCK)
    ON b.[BATCHJOBID] = bj.[RECID] 
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHGROUP] bg WITH(NOLOCK)
    ON bg.[GROUP_] = b.[GROUPID] 
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHHISTORY] bh WITH(NOLOCK)
    ON bh.[BATCHID] = b.[RECID]
    AND bh.[BATCHJOBID] = bj.[RECID]
    AND bh.[BATCHJOBHISTORYID] = bjh.[RECID]
WHERE bjh.[STARTDATETIME] > GETDATE() - 1 -- AND bj.[STATUS] NOT IN(1, 2, 4)

Solution

  • The enum is BatchStatus, which is stored in the modelstore DB, but I don't think the enum names and/or values are stored. It represents an integer ultimately.

    Below is the base enum with the integer values 0-8:

    enter image description here

    The text labels are the same as the name (in English that is) except for the below exceptions.

    You could probably just create a SQL stored procedure with a CASE statement as these statuses are rarely changed from base code.