Dynamics AX Blog - Posts from September 2019

These posts are machine-translated.
Currently, only posts from »September 2019« are displayed Filter entfernen

SysOperation-Framework: Controlling ExecutionMode and server method to be executed using the MenuItem

If you want to control the SysOperationExecutionMode and/or the server method to be executed via the MenuItem in a SysOperation construct, you can control this via the properties of the MenuItem.

Scenario: Without own controller

The following two MenuItems show how to set the properties for them:

This MenuItem calls the runService() method of a service class and sets the SysOperationExecutionMode to Synchronous:

Screenshot


 
 
 

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


 
 
 

 

 
 
 
Posts of the actual month
September 2019
MoTuWeThFrSaSu
 1
2345678
9101112131415
16171819202122
23242526272829
30 
 
© 2006-2024 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.