Welcome at schweda.net | EN | DE
 
 
 
 
 
These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2009« Filter entfernen

Subscribe to RSS feed of this version

Sometimes you have to use special characters in the XML header of a method to document the code well. To get sure, that this header is still well-formed and is not identified as best practice deviation, you can use a CDATA section.

/// <version>
///  1.0
/// </version>
/// <summary>
/// <![CDATA[ Replaces following special characters: &, % ]]>
/// </summary>
private void someMethod()
{
    //...do something...
}

Without this CDATA section AX would spend the following BP-Deviation:

XML documentation is not well-formed.


To list all (shared-) pojects that carry a specific text in the name, you can use the following code.

static void searchProjectName(Args _args)
{
    ProjectNode projectNode;

    #AOTExport

    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfirstChild();

    while(projectNode)
    {
        setPrefix(projectNode.name());

        if(strScan(projectNode.name(), "BR_", 0, 60))
        {
            info(projectNode.name());
        }

        projectNode    = projectNode.AOTnextSibling();
    }
}

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();
    }
}


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:\temp\csvimport.csv";
    CommaTextIo commaTextIo = new CommaTextIo(fileName, "r");
    container lineCon;

    commaTextIo.inFieldDelimiter(';');
    commaTextIo.inRecordDelimiter('\r\n');
    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.


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();
}
 

If you need a so called AX<Table>-class can use the class AxGenerateAxBCClass.

Simply call this class in the AOT by right clicking and follow the wizard or use following job:

static void generateAXTableClass(Args _args)
{
    AxGenerateAxBCClass axGenerateAxBCClass;
   
    axGenerateAxBCClass = new AxGenerateAxBCClass();
    axGenerateAxBCClass.parmTableId(tableNum(MyNewTable));
    axGenerateAxBCClass.run();
}

A that way generated class must be modified sometimes, but using the wizard is much faster than creating the class manually.

If the table changes, for example when adding new fields, you simply call that AxGenerateAxBCClass again and the AX<Table>-class will be extended accordingly.

How to use such AX<Table>-classes, i've described here.


If you want to use a particular dimension as a dialog field in Dynamics AX 2009 (or earlier versions), you can create your own Extended Data Type (derived from Criterias) as described below. The decisive factors are the relations of this EDT.

In the example, the cost center is to be offered as a dialog field.

Screenshot EDT

The example code was taken from a class which extends runBase.


Pages 1 2 3 4 » 

 

 
Feeds
RSS RSS feed
 
 
posts of the actual month
November 2017
MoDiMiDoFrSaSo
 12345
6789101112
13141516171819
20212223242526
27282930 
 
 
© 2006-2016 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.