Monday 17 December 2018

Get Approver name from workflow history - ax 2012

Get Approver name from workflow history




public display Name displayApproverName()
{
    WorkflowTrackingTable           workflowTrackingTable;
    WorkflowTrackingStatusTable     workflowTrackingStatusTable;
    WorkflowTrackingCommentTable    workflowTrackingCommentTable;
    WorkflowTrackingWorkItem        workflowTrackingWorkItem;
    WorkflowWorkItemTable           workflowWorkItemTable;

    select ContextCompanyId, ContextTableId, ContextRecId from workflowTrackingStatusTable
        where workflowTrackingStatusTable.ContextCompanyId    == curext()
           && workflowTrackingStatusTable.ContextTableId      == this.TableId
           && workflowTrackingStatusTable.ContextRecId        == this.RecId
        join firstonly TrackingId, CreatedDateTime,user from workflowTrackingTable order by CreatedDateTime desc
            where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
        join workflowTrackingWorkItem where workflowTrackingWorkItem.WorkflowTrackingTable == workflowTrackingTable.RecId
        join workflowWorkItemTable where workflowTrackingWorkItem.WorkItemId == workflowWorkItemTable.Id  ;

    return workflowWorkItemTable.userName();
}

For more information about this error navigate to the report server on the local server machine, or enable remote errors - ssrs report ax 2012

For more information about this error navigate to the report server on the local server machine, or enable remote errors - generating ssrs report - ax 2012.


Go to SQL server management studio (ssms).

connect to Reporting server - Right Click - select properties

Navigate to Advance - change property 'EnableRemoteError' to 'True'.




Tuesday 11 December 2018

use AOT query in code


use AOT query in code
static void Job10(Args _args)
{

    CustInvoiceJour custInvoiceJour;
    Query           query = new Query(queryStr (InventJournalTrans)); // Query name.
    QueryRun        qr;
    QueryBuildRange qbr;
    InventJournalTrans inventJournalTrans;
    MainAccount mA;
    DimensionAttributeValueCombination dimensionAttributeValueCombination;
    HcmWorker hcmWorker;
    JournalError    journalError;
    InventDim   inventDim;
    // Find the InvoiceDate range on AOT Query.
    qbr = query.dataSourceTable( tablenum (InventJournalTrans))
            .findRange( fieldNum (InventJournalTrans, JournalId));

    // We can check if the query range does exist, if not, we can create it.
    if (!qbr)
    {
        qbr = query.dataSourceTable( tableNum (InventJournalTrans))
            .addRange( fieldNum (InventJournalTrans, JournalId));
    }

    // Assigning query range value.
    qbr.value('IJN006806');


    // Executing our query.
    qr = new QueryRun(query);

    // Looping through query results.
    while (qr.next())
    {
        // Assinging query results to table buffer.
        inventJournalTrans = qr.get(tableNum(InventJournalTrans));
        mA = qr.get(tableNum(MainAccount));
        dimensionAttributeValueCombination  = qr.get(tableNum(DimensionAttributeValueCombination));
        inventDim = qr.get(tableNum(InventDim));
        // Showing results.
        info( strFmt ('%1 - %2 - %3' , inventJournalTrans.JournalId,
                                    dimensionAttributeValueCombination.RecId,
                                    inventDim.RecId));
    }