Dynamics AX Blog - Dynamics AX 2012 - Microsoft Dynamics AX (Axapta) - Page 10

These posts are machine-translated.
Currently, only posts from category »Microsoft Dynamics AX (Axapta)« are displayed Filter entfernen

In recent years, i spent a lot of time in developing in the environment of Microsoft Dynamics AX (formerly Axapta). During this time i created a lot of code, from which I could imagine, that it might be very useful for other AX developers too. But I will present also tips and tricks round the powerful ERP system.

Subscribe to RSS feed of this category
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2012« Filter entfernen

RSS-Feed of this version

Error "Invalid object name" in form Security entry point permissions

When using the form "Security entry point permissions" the following error may occur when changing the field "Type":

Invalid object name.

The cause is that the tool tries to create an object in the AOT having the user id as part of its name. When this user ID contains characters that are not allowed in an object name (for example dashes), the error is thrown.

Simplest workaround: Using another user.


 
 

Creating Sysoperation classes through code

Anyone who has ever implemented a function using the SysOperation framework knows that creating the necessary (up to) four classes is some work.

ScreenshotFor lazy efficient contemporaries I have therefore developed the following job, with the help of this time-consuming work can be significantly shortened.

In the job you have to set an "base name", which is used for naming the four classes (Controller, Dataprovider, UIBuilder and Service).

In addition there is a map called dataContractParmsMap from - unless you have inserted content in this map - matching parm methods are created when generating the data provider. In example job the map contains two entries for a customer account number and an item number.


 
 

Calling a SysOperation-based function through code

If you need to run a function - implemented by using the SysOperation-Framework - by code, the following job can show you how you can do this.

static void runSysOperationThroughCode(Args _args)
{
    TutorialSysOperationServiceController controller;
    TutorialSysOperationDataContract dataContract;
    SysOperationStartResult sysOperationStartResult;
    
    controller = TutorialSysOperationServiceController::newFromArgs(new Args()); 

    dataContract = controller.getDataContractObject('_dataContract'); 

    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous); 

    dataContract.parmFilenameSave(@"c:	empmyFile.txt");
    dataContract.parmCustAccount('US-006');
       
    sysOperationStartResult =
    controller.startOperation();
}

 
 

Debugging SSRS-Dataprovider

In the past i often had the problem, that i had to debug a dataprovider of a SSRS-Report, which could not be debugged using the well known Dynamics AX Debugger (for example because the dataprovider is executed only on server).

Therefore i created the below job (DataProvider has to extend SRSReportDataProviderBase), which only puts the content of the created (temporary) table to an simple infolog.

In the example the report "Work note" of the service module is used.

static void testSSRSDatProvider(Args _args)
{
    SMAWorkNoteTmp      tempTable;
    SMAWorkNoteDP       dataProvider = new SMAWorkNoteDP();
    SMAWorkNoteContract contract = new SMAWorkNoteContract();
    Query               query = new Query(identifierStr(SMAWorkNote));

    try
    {
        SysQuery::findOrCreateRange(
            query.dataSourceTable(
                tableNum(SMAServiceOrderTable)),
                fieldNum(SMAServiceOrderTable, ServiceOrderId)).value("00018");

        contract.parmItemConsumption(true);
        contract.parmItemRequirement(true);
        contract.parmExpense(true);
        contract.parmFee(true);
        contract.parmAdditionalNotes(true);
        contract.parmLineText(true);

        if( !contract.validate())
        {
            throw error(error::missingParameter(contract));    
        }

        dataProvider.parmDataContract(contract);
        dataProvider.parmQuery(query);
        dataProvider.processReport();

        tempTable = dataProvider.getSMAWorkNoteTmp();

        while select tempTable
        {
            info(tempTable.otServiceOrderId);
        }
    }
    catch (Exception::Break)
    {
        info("Aborted");
    }
}

 
 

Add prefixes to infolog-messages

With setPrefix () you can easily create nested messages in the infolog.
What I not knew before is, that you can integrate those prefixes directly in the message, simply by expanding the actual message to the desired heading and the control character for a tabulator.

static void inlinePrefix(Args _args)
{
    setPrefix("Inhaltsverzeichnis");
    info("Kapitel 1	Seite 1");
    info("Kapitel 1	Seite 2");
    info("Kapitel 1	Seite 3");
    info("Kapitel 2	Seite 4");
    info("Kapitel 2	Seite 5	Abschnitt 1");
    info("Kapitel 2	Seite 5	Abschnitt 2");
    info("Kapitel 2	Seite 6");    
}

The created infolog will look like this:

Infolog


 
 

Block journal through code

A common requirement in project life is to create journals of various types per code.

I recently had a similar requirement, but the Journal should not be posted immediatily, but it should be ensured that these journals are not unintentionally changed by other users.

And precisely for this requirement, the following code is intended:

JournalTableData::updateBlockServer(
    prodJournalTable, 
    JournalBlockLevel::None, 
    JournalBlockLevel::InUse, 
    false);

 


 
 

How to create a non-primary address in global adressbook

Example of how you can create a non-primary address for an entry in the global address book via code.

static void createPartyAddressNonPrimary(Args _args)
{
    DirPartyTable dirPartyTable = DirPartyTable::findByNum("???100000??");
    DirParty dirParty;
    DirPartyPostalAddressView dirPartyPostalAddressView;

    // Create instance of dirParty
    dirParty = DirParty::constructFromCommon(dirPartyTable, DirUtility::getCurrentDateTime(), dirPartyTable.partyType());

    // Create primary address
    dirPartyPostalAddressView.LocationName      = "Delivery";
    dirPartyPostalAddressView.City              = "Vienna";
    dirPartyPostalAddressView.Street            = "Kärtnerring";
    dirPartyPostalAddressView.StreetNumber      = "21";
    dirPartyPostalAddressView.CountryRegionId   = "AUT";
    dirPartyPostalAddressView.IsPrimary         = NoYes::No;

    dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
}

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

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 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.