Dynamics AX Blog - Dynamics AX 2012 - Page 11

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

Open query window when opening form

To open the query-windows when opening a form, you can use the following code for example:

public void run()
{
    super();
    if(dataSourceName_ds.queryRun().prompt())
    {
        dataSourceName_ds.research();
    }
}

 


 
 

Cancel salesline through code

The code is based on the logic in the form SalesUpdateRemain ("Deliver remainder" button in the sales order header).

static void cancelSalesLine(Args _args)
{
    boolean updated;
    SalesLine salesLine; 
    
    try
    {
        ttsBegin;        
        
        salesLine = SalesLine::findInventTransId('012411', true);
    
        updated = SalesUpdateRemain::updateDeliveryRemainder(salesLine, 0, 0);
    
        if(updated)
        {
            info("Salesline canceled");    
        }        
        
        ttsCommit;
    }
    catch
    {
        error("SalesLine could not be canceled");
    }
}

 
 

List all modified objects from current layer, which are not added to versioncontrol

Using the SysModel* tables, you can browse the AOT to certain objects or their properties in Dynamics AX. I've posted an example already here.

The following job is an extension of the above posting and lists all objects that have been changed in the current layer and still were not added to version control.


 
 

SysOperation: Open form with specific record after processing

Imagine the following scenario: You have to create or update a record using a clas, which extends Sysoperation-Framework. After this database operation you have to open a particular form, which allows the user to modify the just created/modified record.

For such tasks i like to use the aferoperation()-method from the Controller-Class. By using the operationReturnvalue of the Service-Class within this method it is possible to process the record.


 
 

Import data from csv-file to Dynamics AX

Using the CommaTextIo class you can import CSV files into Dynamics AX. The job shows a simple example of using this class.

static void importCSVFile(Args _args)
{
    Filename fileName = @"c:	empcsvimport.csv";
    CommaTextIo commaTextIo = new CommaTextIo(fileName, "r");
    container lineCon;

    commaTextIo.inFieldDelimiter(';');
    commaTextIo.inRecordDelimiter(' ');
    while (commaTextIo.status() == IO_Status::OK)
    {
        lineCon = commaTextIo.read();

        info(strFmt("%1 %2 %3", conPeek(lineCon, 1), conPeek(lineCon, 2), conPeek(lineCon, 3)));
    }
}

In principle, this would also work with the TextIo class (or AsciiIo), but it must be noted that these classes can provide unexpected results when, for eample the inFieldDelimiter - in my example a semicolon - occurs within a text.

 

The following sample file would otherwise be processed, as expected from the developer. The third column in the third row would be interpreted as two columns by the read()-method.

100;450,00;Customername1
101;1200,00;Customername2
102;50,28;"Customername 3; Second customername"

 
 

Get label from MenuItem

static void getLabelFromMenuItem(Args _args)
{
    MenuItemBuild menuItemBuild = new menuItemBuild(menuitemDisplayStr(ProdTableDelayedListPage), MenuItemType::Display);
    
    info(menuItemBuild.menuFunction().label());
}

 
 

Create purchase order line through code

A simple example of how to create a purchase order line through code using AX<Table>-Class.

static void createPurchLine(Args _args)
{
    axPurchLine axPurchLine;
    purchLine purchLine;
   
    axPurchLine = AxPurchLine::newPurchLine(purchLine);
    axPurchLine.validateInput(true);
    axPurchLine.continueOnError(false);
   
    axpurchLine.parmPurchId("P00001");
    axpurchLine.parmItemId("1000");
    axPurchLine.parmPurchQty(10);
    axPurchLine.parmPurchPrice(24.50);
    axPurchLine.save();
}

 
 
Pages « 1 ... 8 9 10 11 12 13 14 ... 22 » 

 

 
 
 
Posts of the actual month
Mai 2024
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 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.