Dynamics AX Blog - Posts from Mai 2015

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

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

 
 
 

How to create a AX<Table>-Class II

If you need a so called AX-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

-class will be extended accordingly.

 

How to use such AX

-classes, i've described here.

 


 
 
 

Add contact information for entity

Here is an example of how you can add contact information data to an existing entry in the global address book.

static void createPartyContactInfo(Args _args)
{
    DirPartyTable dirPartyTable = DirPartyTable::findByNum(??"100000");
    DirParty dirParty;
    DirPartyContactInfoView dirPartyContactInfoView;

    // Edit Global address book
    dirParty = DirParty::constructFromCommon(dirPartyTable, DirUtility::getCurrentDateTime(), DirPartyType::Organization);

    // Create contact info
    dirPartyContactInfoView.LocationName    ='Office';
    dirPartyContactInfoView.Locator         ='+43 1 4654646';
    dirPartyContactInfoView.Type            = LogisticsElectronicAddressMethodType::Phone;
    dirPartyContactInfoView.IsPrimary       = NoYes::Yes;

    dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}

Such a created entry will look like this:

Screenshot


 
 
 

 

 
 
 
Posts of the actual month
Mai 2015
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2025 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.