Dynamics AX Blog - Dynamics AX 2012

These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2012« Filter entfernen

RSS-Feed of this version

SysOperation-Framework: Force Batch Processing

If you want to make sure that a function implemented via the SysOperation-framework is always executed via batch processing, you can set the SysOperationExecutionMode to ScheduledBatch (e.g. via the MenuItem of the controller - see here).

If this is a function that requires a user dialog, however, the problem is that the "Batch" tab is displayed by default and, for example, the "Batch" check box is not activated there.

Of course you can activate this checkbox by including a call to parmBatchExecute() in the UIBuilder:

public void build()
{
    super();

    this.controller().batchInfo().parmBatchExecute(this.controller().parmExecutionMode() == SysOperationExecutionMode::ScheduledBatch);
}

 
 
 

Creating and posting a free text invoice by code

The following job shows how to create and post a free text invoice by code.

static void createAndPostFreeTextInvoice(Args _args)
{
    CustInvoiceTable custInvoiceTable;
    CustInvoiceLine custInvoiceLine;
    DimensionDefault dimensionDefault; 
    LedgerDimensionAccount ledgerDimensionAccount;     
    CustPostInvoice custPostInvoice;
    
    try
    {
        ttsBegin;        
        
        // Create header
        custInvoiceTable.clear();
        custInvoiceTable.initValue();
        custInvoiceTable.OrderAccount = "US-004";
        custInvoiceTable.modifiedField(
            fieldNum(CustInvoiceTable, OrderAccount));
        custInvoiceTable.insert();
        
        // Create line
        custInvoiceLine.clear();
        custInvoiceLine.initValue();
        custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
        custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);
        custInvoiceLine.Description = "Test";
        custInvoiceLine.Quantity = 10;
        custInvoiceLine.modifiedField(
            fieldNum(CustInvoiceLine, Quantity));
        custInvoiceLine.UnitPrice = 200;
        custInvoiceLine.modifiedField(
            fieldNum(CustInvoiceLine, UnitPrice));
        
        ledgerDimensionAccount = 
        DimensionDefaultingService::serviceCreateLedgerDimension(
            DimensionStorage::getDefaultAccountForMainAccountNum(
                "110110"), 
                dimensionDefault); 
        
        custInvoiceLine.LedgerDimension = ledgerDimensionAccount;
        custInvoiceLine.modifiedField(
            fieldNum(CustInvoiceLine, LedgerDimension));
        custInvoiceLine.insert();
        
        // Post
        custPostInvoice = new CustPostInvoice(custInvoiceTable);
        custPostInvoice.run();
        
        ttsCommit;
    }
    catch
    {
        throw error(error::wrongUseOfFunction(funcName()));
    }
}

This is what a free text invoice looks like:

Screenshot Freetext invoice


 
 
 

Debugging SSRS-Dataprovider which extends SrsReportDataProviderPreProce

In Debugging SSRS-Dataprovider I have already described how to "debug" a DataProvider derived from SRSReportDataProviderBase.

The following job basically does the same, but for preprocessed reports, where the DataProvider is derived from SrsReportDataProviderPreProcess. In the example, I use the DataProvider of an invoice (SalesInvoice).

static void testSSRSDataProvider_SalesInvoice(Args _args)
{
    SalesInvoiceTmp salesInvoiceTmp;
    SalesInvoiceDP dataProvider = new SalesInvoiceDP();
    SalesInvoiceContract contract;
    CustInvoiceJour CustInvoiceJour = CustInvoiceJour::findRecId(35637191172);
    UserConnection UserConnection;

    try
    {
        ttsBegin;

        UserConnection = new UserConnection();

        contract = new SalesInvoiceContract();
        contract.parmFormLetterRecordId(CustInvoiceJour.RecId);
        contract.parmRecordId(CustInvoiceJour.RecId);

        dataProvider = new SalesInvoiceDP();
        dataProvider.parmDataContract(contract);
        dataProvider.parmUserConnection(UserConnection);
        dataProvider.processReport();

        salesInvoiceTmp = dataProvider.getSalesInvoiceTmp();
        
        while select salesInvoiceTmp
            where SalesInvoiceTmp.createdTransactionId == appl.curTransactionId()
        {
            info(strFmt("%1 %2", SalesInvoiceTmp.InvoiceId, SalesInvoiceTmp.ItemId));
        }

        ttsCommit;
    }
    catch (Exception::Break)
    {
        info("Aborted");
    }
}

 


 
 
 

Pick a reserved sales order line by code

To pick the quantities already reserved from an sales order item by code, you can use codes such as the following:

static void JobPick(Args _args)
{
    Query inventTransQuery;
    QueryRun qr;
    QueryBuildDataSource qbds;
    InventTrans inventTrans;
    InventDim inventDim;
    InventTransOrigin inventTransOrigin;
    TmpInventTransWMS tmpInventTransWMS;
    InventTransWMS_Pick inventTransWMS_Pick;
    SalesLine salesLine = SalesLine::findInventTransId('014417');
    
    inventTransQuery = new Query();
    qbds = inventTransQuery.addDataSource(tableNum(InventTrans));
    qbds.addRange(fieldNum(InventTrans, StatusIssue)).value(queryValue(StatusIssue::ReservPhysical));
    qbds = qbds.addDataSource(tableNum(InventTransOrigin));
    qbds.relations(true);
    qbds.joinMode(JoinMode::InnerJoin);
    qbds.addRange(fieldNum(InventTransOrigin, InventTransId)).value(salesLine.InventTransId);
    
    qr = new QueryRun(inventTransQuery);
    while (qr.next())
    {
        inventTrans = qr.get(tableNum(InventTrans));
        inventTransOrigin = qr.get(tableNum(InventTransOrigin));
        
        // Set inventory dimensions for picking
        inventDim = inventDim::find(inventTrans.InventDimId);
        inventDim.wmslocationId = "06A01R3S1B";   
        inventDim.LicensePlateId = "LP_61_A0001";
        inventDim = inventDim::findOrCreate(inventDim);
        
        tmpInventTransWMS.clear();
        
        inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInventTransWMS, inventTransQuery);
        
        tmpInventTransWMS.initFromInventTrans(InventTrans);
        tmpInventTransWMS.initFromInventTransOrigin(inventTransOrigin);
        tmpInventTransWMS.initFromInventDim(inventDim);
        
        tmpInventTransWMS.InventQty = -inventTrans.Qty;
        
        inventTransWMS_Pick.writeTmpInventTransWMS(tmpInventTransWMS);
        inventTransWMS_Pick.updateInvent();    
    }
}

 
 
 

Impact Analysis Tool fails when deleting the baseline database

Recently when running the Impact Analysis Tool I had the problem that the installer seemed to have a problem deleting the baseline database and stopped/handled at this point. By the way, there was no entry in the event log.

Screenshot Impact Analysis Tool

Interestingly, I also couldn't see the properties of the baseline database via SQL Server Management Studio, and the following error occurred:

Property Size is not available for Database '[AX2012R3_Baseline]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.  (Microsoft.SqlServer.Smo)

So I have suspected that the database is broken in some way. Therefore I simply tried to re-initialize the baseline database via AXUTIL, which finally fixed my bug:

axutil schema /DB:AX2012R3_Baseline /S:MyServerName

After initializing the database I was able to start the Impact Analysis Tool without any problems.


 
 
 

SysOperation-Framework: Usage data per MenuItem

Imagine you have a function build using the SysOperation framework that can be called at different places in the system, and you want to make sure that these calls do not share the same usage data.

In such a case you could create two (or more) MenuItems and override the method lastValueDesignName() of the controller as follows. This will store separate usage data for each MenuItem.

protected IdentifierName lastValueDesignName()
{
    IdentifierName ret;

    ret = super();

    if (this.parmArgs() && this.parmArgs().menuItemName())
    {
        ret = this.parmArgs().menuItemName();   
    }

    return ret;
}

 
 
 

Query/QueryRun using a temporary table

If you want to run through the contents of a temporary table with a QueryRun, you have to use the method setRecord() of the QueryRun object.

Simple example

static void Job1(Args _args)
{
    TmpFrmVirtual tmpFrmVirtual;
    InventTable inventTable;
    Query q;
    QueryRun qr;
    QueryBuildDataSource qbds1, qbds2;
    
    TmpFrmVirtual populateTmpFrmVirtual()
    {
        TmpFrmVirtual tmpFrmVirtualLocal;    
        
        tmpFrmVirtualLocal.clear();
        tmpFrmVirtualLocal.ItemId = "A0001";
        tmpFrmVirtualLocal.insert();
        
        tmpFrmVirtualLocal.clear();
        tmpFrmVirtualLocal.ItemId = "A0002";
        tmpFrmVirtualLocal.insert();        
        
        tmpFrmVirtualLocal.clear();
        tmpFrmVirtualLocal.ItemId = "A0003";
        tmpFrmVirtualLocal.insert();          
        
        return tmpFrmVirtualLocal;
    }
    
    q = new Query();
    qbds1 = q.addDataSource(tableNum(TmpFrmVirtual));
    
    qr = new QueryRun(q);
    qr.setRecord(populateTmpFrmVirtual());
    while (qr.next())
    {
        tmpFrmVirtual = qr.get(tableNum(tmpFrmVirtual));    
        
        info(tmpFrmVirtual.ItemId);
    }  
}

 
 
 
Pages 1 2 3 4 ... 21 » 

 

 
 
 
Posts of the actual month
September 2019
MoTuWeThFrSaSu
 1
2345678
9101112131415
16171819202122
23242526272829
30 
 
© 2006-2019 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.