Search This Blog

July 25, 2012

How to fetch Values from WorkFlow Tables

How to fetch Values from WorkFlow Tables

Hi friends,
   I am facing a problem since many days and now i got the logic to fetch values from a workflow table, but still it’s for only PO and PR and i am working on the GL transaction also, here is the Code, Use copy and paste it in a job and run.

static void theaxapta_WorkflowHisory()
    WorkflowTrackingTable           workflowTrackingTable;
    WorkflowStepTable               workflowstepTable;
    WorkflowTrackingStatusTable     workflowTrackingStatusTable;
    WorkflowTrackingCommentTable    workflowTrackingCommentTable;

    utcdatetime     dt[];
    string100     Comment;
    int i;
    i = 1;
   select workflowtrackingtable join workflowsteptable
    where workflowsteptable.StepId == workflowtrackingtable.StepId
    &&    workflowtrackingtable.ContextRecId == PurchTable::find('NBH1112_PO000025').RecId;

   while select workflowtrackingtable
            where  workflowtrackingtable.ContextRecId == PurchTable::find('NBH1112_PO000025').RecId

        dt[i] = workflowtrackingtable.createdDateTime;
        i ++;
        info(strfmt("Step Name == %1......  user Code: %2", workflowsteptable.Name,  workflowtrackingtable.User));
    info(strfmt('User Approved: %1 - %2.....%3......%4.......%5..........', dt[1], dt[2],dt[3],dt[4]));

    select workflowTrackingCommentTable  where workflowTrackingCommentTable.TrackingId == workflowTrackingTable.TrackingId;
    while select workflowTrackingCommentTable  where workflowTrackingCommentTable.TrackingId == workflowTrackingTable.TrackingId
        info(strfmt("Comment...=  %1",workflowTrackingCommentTable.TrackingMessage));

//    select workflowTrackingCommentTable
//    where workflowTrackingCommentTable.TrackingId == workflowTrackingTable.TrackingId;
//    info(strfmt('Date Approved: %1', workflowTrackingCommentTable.TrackingMessage, DateTimeUtil::applyTimeZoneOffset(workflowTrackingCommentTable.createdDateTime, DateTimeUtil::getUserPreferredTimeZone())));


Note: This is rough code, you may need to update it as per your requirement.


  1. this code is just a reference . if you want to get complete code plz let me know.... :)

  2. Hi Bhaga,

    By the way, which version of AX you are using?