search

Art Of Creation – Dynamics AX Blog

 The everyday life of a Dynamics AX developer

  • Pages

    • AX links
    • Contact
  • Popular Posts

    • AIF: The path %1 does not exist or is not accessible from an AOS server. Always use a UNC path.
    • Show AOS in status bar
    • Run multiple jobs
    • New AX blog: ax@luegisdorf
    • Launching Dynamics AX using Launchy
  • Recent Comments

    • Philippe V on Axapta 3 menu in AX 2009
    • Luegisdorf on Lookup() override does not work
    • Jeroen Doens on Launching Dynamics AX using Launchy
    • BrianS on Dynamics AX Wallpaper
    • Malcolm Burtt on While select firstonly
  • Tags

    AIF AOS Application Batch bookmarks CLR Compiler Configuration Database Data Types Debug Dynamics AX Editorscripts Error Event Log Extensions Fun Google Inheritance Job link lookup Nice-to-haves RPC security SQL String System.Diagnostics System.IO TechDays Tools Wallpaper WinAPI
  • Ax Dev Twitter

    • Don't query, be happy.
    • Microsoft Confirms Dynamics AX Compatibility with Windows 7: http://tinyurl.com/ykewlvh
    • There is *only one* article about "Dynamics Ax" on slashdot.org
    • Remember to use compile forward when modifying classes that are inherited by other classes!
    • X++ editor: pressing ctrl + space on a label to know the text is much faster than using the label editor.
    • Microsoft released hotfixes for Ax 2009 that fix "Internal error 25 in script". KB973902 and KB948130 for more information.
    • X++ editor: double click on text between double quotes and only the text will be selected, with single quotes, the quotes get selected too.
    • Each line of a stack trace starts with (S) or (C). (S) indicates the code was running on the server, (C) that it was running on the client.
    • In the X++ code editor, Ctrl + L will delete a complete line of code.
    • Microsoft Excel is *very* fast at doing "find and replace" on large text documents. Much faster than Notepad, TextPad or Notepad++.
  • Microsoft TechDays 2010 Antwerp

    February 5, 2010 at 14:46  (no comments)

    On March 31 and April 1, I will be attending Microsoft TechDays 2010 conference in Antwerp, Belgium. Me and my colleagues will be wearing a T-shirt that says RealDolmen (no doubt followed by a catchy slogan the PR people will come up with).

    With over 80 sessions from international speakers to choose from, it will be difficult to pick the most interesting ones.

    See you at TechDays.

    Link: Microsoft TechDays 2010

  • Str2int and IsInteger

    February 4, 2010 at 12:16  (no comments)

    Here’s a little ‘be-aware’ I’d like to share.

    The function str2int() that converts a string to an integer will return ‘0′ if the input string is not an integer, so it is necessary to check if the string is an integer before casting it.

    The function that does this is not IsNumeric() like in SQL or VB, but IsInteger().
    Alternatively, you can also use str2IntOk(). Both are found in the global class.

    I’ve seen people searching for this method (including me), so I just thought I’d share.

    Here’s some sample code:

    static void klforStr2intAndIsIntegerTest(Args _args)
    {
        str input_notint    = "abc123";
        str input_int       = "123";
       
        int ret;
        ;
       
        // be aware, str2int will convert 'non integers' to '0'
        // without warning
        info(strfmt("%1", str2int(input_notint)));
        info(strfmt("%1", str2int(input_int)));
       
        // you can check if a string is an integer with
        // the isInteger() function from the global class
        // or you the str2IntOk() function
        info(strfmt("%1", isInteger(input_notint)));
        info(strfmt("%1", isInteger(input_int)));
       
        // check if integer
        if(isInteger(input_notint))
        {
            // cast to integer
            ret = str2int(input_notint);
        }
        else
        {
            throw error(strfmt("'%1' is not an integer", input_notint));
        }
    }
  • Delete an AX company on SQL

    February 3, 2010 at 21:03  (no comments)

    This week, we were shrinking a database of a development environment by deleting some companies.
    Here a nice little SQL statement that uses the sp_MSforeachtable stored procedure to delete all records of a specific company (CEU in this case) from all tables.

    exec sp_MSforeachtable 'delete from ? where ?.DataAreaID = "CEU"'

    Certainly fast(er than AX) and gets the job done.
    Use at your own risk ;-)

  • Axapta 3 menu in AX 2009

    January 28, 2010 at 18:58  (1 comment)

    Are you one of those people who always minimize the content pane in AX 2009?
    Are you one of those people who don’t know what the breadcrumb on top of the AX screen is for?
    Do you already execute a job to disable the content pane on startup?

    Then you might feel totally nostalgic when you see the Axapta 3 menu appearing after you run the following job in AX 2009.

    static void Axapta30Nostalgia(Args _args)
    {
        Menu menu;
        #admin
        ;
       
        menu = new Menu(#MainMenu);
        menu.AOTrun();
    }
  • Microsoft Dynamics AX 2009 Development Cookbook

    January 12, 2010 at 19:11  (no comments)

    A new book written by Mindaugas Pocius about AX development was published last month: Microsoft Dynamics AX 2009 Development Cookbook.

    The book contains step-by-step instructions along with screenshots and aims at Dynamics AX developers of beginner and intermediate level.

    To give you an idea, here are the chapters:
    Chapter 1: Processing Data
    Chapter 2: Working with Forms
    Chapter 3: Working with Data in Forms
    Chapter 4: Building Lookups
    Chapter 5: Processing Business Tasks
    Chapter 6: Integration with Microsoft Ofice

    You can buy the book, eg on Amazon.com or at Packt Publishing.

    You can also download the sample code used in the book.

  • Lookup() override does not work

    January 9, 2010 at 11:03  (1 comment)

    I had this situation where overriding the lookup() method on a field on a form was not working.
    The problem was the AutoDatagroup property on the field group on my grid.
    When this property is set to Yes, the lookup override will not work.

    AutoDataGroup

    Also, when you change this property from ‘No’ to ‘Yes’ when methods have been added or overridden on the fields, the methods wil be cleared and you will loose your code.

    Update: see comment by Luegisdorf about overwriting this method in datasource in stead of the control.

  • Get folders and subfolders

    January 8, 2010 at 19:34  (no comments)

    Someone on the Microsoft AX newsgroups asked how to get a list of directories and subdirectories given a folder. Here a job that does that:

    static void KlForLoopFoldersSystemIO(Args _args)
    {
        int                 k;                  // counter for result loop
        container           dirs;               // container for result
        filePath            path = @"C:\temp";  // input path

        container getDirectories(str _dir, boolean _inclSubDirs = true)
        {
            container           dList;          // container to cast array into
            int                 i;              // counter for array loop
            System.Array        directories;    // array for result from .NET call
            #Define.Pattern("*")                // input pattern: * = all
            ;

            // assert interoppermissions for .NET interop
            new InteropPermission(InteropKind::ClrInterop).assert();

            // get directories using .NET interop
            if(_inclSubDirs)
            {
                // include subdirectories
                directories = System.IO.Directory::GetDirectories(_dir, #Pattern, System.IO.SearchOption::AllDirectories);
            }
            else
            {
                // only top directory
                directories = System.IO.Directory::GetDirectories(_dir, #Pattern, System.IO.SearchOption::TopDirectoryOnly);
            }

            // loog .NET array and put the values in a container for easier use in x++
            for( i=0;i<ClrInterop::getAnyTypeForObject(directories.get_Length()); i++ )
            {
                dList = conins(dList, conlen(dList)+1, ClrInterop::getAnyTypeForObject(directories.GetValue(i)));
            }

            // revert assertion to prevent multiple calls to the assert() method
            CodeAccessPermission::revertAssert();

            // return result container
            return dList;
        }
        ;

        // get directories
        dirs = getDirectories(path);

        // use optional parameter to disable sub directories
        // dirs = getDirectories(path, false);

        // print the result
        for(k=1;k<= conlen(dirs); k++)
        {
            // print the result to screen
            info(conpeek(dirs, k));
        }

        // we're done
        info("done");
    }
  • Check what application and database you are connected to

    January 4, 2010 at 19:27  (no comments)

    If you want a quick way to check to what database and application folder you are connected, you can use the ‘Upgrade checklist’ form:

    Administration – Setup – System – Checklists – Upgrade checklist.

    It shows you:
    - Database server
    - Database name
    - Application folder
    - Layers in the application

    Upgrade Checklist

    Upgrade Checklist

  • Launching Dynamics AX using Launchy

    December 29, 2009 at 13:18  (1 comment)

    There are a few tools I use daily that I really couldn’t live without. One of them is Launchy, by Josh Karlin (launchy.net).

    From the website:

    Launchy is a free windows and linux utility designed to help you forget about your start menu, the icons on your desktop, and even your file manager.

    And it really does just that. You won’t be using the Start menu anymore once you’ve installed this tool.

    You can download it here.

    Once you’ve installed it, you will see… nothing, untill you hold Alt and tap Space.
    Then you see something like this:

    Once you start typing, say “Dynami…”, Launchy searches for programs that match the string you are typing. Tap Enter to launch the program.

    You can use Launchy to launch specific AX configurations by creating a folder that contains axc files.

    Go to the AX Client Configuration Tool, create your configurations and export them using Manage – Safe configuration file to store them in a folder.

    You can setup Launchy to monitor this folder by holding Alt, tapping Space, right clicking on the Launchy window and clicking Options. On the tab Catalog, you should see something like the screenshot below. As you can see, I have already added the folder and the extension axc to the list.

    Launchy options screen

    Launchy options screen

    Now you only need to click the Rescan Catalog button, and you’re set to go.

    The end result should be something like this:

    You should be able to launch right into any AX application with minimal effort now.
    And of course, you can use Launchy to launch any other program as well.

    Links:
    Launchy website: launchy.net
    Inspiration for this post: SmartStart 3000 Central

  • New AX blog: ax@luegisdorf

    December 28, 2009 at 10:37  (no comments)

    There is a new AX blog in the blogosphere by Patrick Kränzlin, nicknamed Luegisdorf. Patrick is very active on the Dynamics AX newsgroups, and is also the author of SmartStart 3000 Central, a tool for managing and launching Dynamics AX configurations and applications.

    Be sure to check out his website, and his first post about reflection:
    How to ignore Private, Protected and Abstract modifiers.

  • AIF: The path %1 does not exist or is not accessible from an AOS server. Always use a UNC path.

    December 8, 2009 at 18:03  (no comments)

    Hi guys,

    It seems like I’m going to be doing a lot of AIF in the future, so I’d like to share the first AIF error I came across:

    The path C:\AIF does not exist or is not accessible from an AOS server. Always use a UNC path.

    You can get this error when setting up channels.
    While I immediately know what the problem was (you have to use shares), my less technical-minded colleague didn’t know what to do.

    This is what Wikipedia has to say about ‘UNC path’:

    The Microsoft Windows UNC, short for Universal Naming Convention or Uniform Naming Convention, specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. The UNC syntax for Windows systems has the generic form:

    \\ComputerName\SharedFolder\Resource

    So there you have it, you have to use a shared folder in stead of a local folder.
    This is logical, as AIF runs on server, and the AOS can not access your local folders.

  • Show AOS in status bar

    November 26, 2009 at 20:04  (no comments)

    There is an option on the ’status bar’ tab of the options screen (AX button – Extra – Options), that some people think that doesn’t work: Show AOS name.
    You can see what I mean on the screenshot below.

    Show AOS name

    Show AOS name


    As you can see, the AOS is clearly displayed at the bottom of the screen in the status bar.
    If the option doesn’t work for you, it is because you did not specify the Instance Name in your client configuration, as shown on the screenshot below.
    Instance name

    Instance name


    You’ll have to restart AX for this to be visible in the status bar.

    Also note that this doesn’t really show the AOS you are connected to, it merely shows the value you specified in the instance name field in your configuration.

    So does this functionality work? Yes, but not as you’d expect.

  • Run multiple jobs

    November 5, 2009 at 18:34  (no comments)

    I’ve noticed some people are visiting this blog looking for code that runs multiple jobs, so here’s a job that does just that.

    static void KlFor_runMultipleJobsContainer(Args _args)
    {
        #AOT                    // macro for treenode paths
        Container   jobCont;    // container for jobs
        int         i;          // counter for loop
        ;

        // add jobs to the container
        jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob2");
        jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob3");
        jobCont = conins(jobCont, conlen(jobCont) + 1, "klforjob2");    // run klforjob2 again

        // loop all elements of the container
        for(i = 1; i <= conlen(jobCont); i++)
        {
            // check if the job exists to avoid errors
             if(TreeNode::findNode(strfmt(#JobPath, conpeek(jobCont, i))))
            {
                // run job
                TreeNode::findNode(strfmt(#JobPath, conpeek(jobCont, i))).AOTrun();
            }
        }
    }

    Easy enough :) .

  • Append text from one file to an other

    October 31, 2009 at 08:28  (1 comment)

    This method will append all text from the original file to the destination file.
    While this is a very easy task, the method shows many of the things you come across when you are working with files in AX, like:

    - Using the #File macro
    - Asserting FileIOPermission to be able to access files
    - Asserting InteropPermission to be able to use .NET Interop
    - Using a set to assert multiple permissions at once
    - Using .NET Clr Interop in AX (better than winapi and winapiserver)
    - Optional cleaning up after you’re done using reverAssert()

    void AppendFileToFile(FileName original, FileName distination)
    {
        #File
        FileIOPermission    FileIOPermissionA   = new FileIOPermission(distination, #io_append);
        FileIOPermission    FileIOPermissionR   = new FileIOPermission(original, #io_read);
        InteropPermission   InteropPermission   = new InteropPermission(InteropKind::ClrInterop);
        Set                 permissionset       = new set(types::Class);
        ;

        // create permissionset
        permissionset.add(FileIOPermissionA);
        permissionset.add(FileIOPermissionR);
        permissionset.add(InteropPermission);
        // assert permissions
        CodeAccessPermission::assertMultiple(permissionset);
        // append text from source file to destination file
        System.IO.File::AppendAllText(distination, System.IO.File::ReadAllText(original));

        // limit the scope of the assert
        CodeAccessPermission::revertAssert();
    }

    Because all permissions are taken care of, this code will run client side as well as server side.

  • Check up on compilation status

    October 30, 2009 at 19:32  (no comments)

    A (little) trick in between. I thought everyone was using this method, but I apparently I was wrong, so here you go.

    Doing a full compile takes a long time, and because of that, it’s handy to be able to check how much of the process is done and how much remains.
    Luckily, when doing a full compile, the Compiler Output form appears at the bottom of the screen where you can see what is currently being compiled.

    The only problem is that most of the time, the AX client hangs and is not responsive during the compilation process, so you can’t see that information.

    The solution to this is to press Crtl + Break.
    You will see a window that says:

    Are you sure that you want to cancel this operation?
    To start the Debugger for Microsoft Dynamics, press and hold SHIFT while you click No.

    While this screen is active, the Compiler Output form will update so you can check up on the status. When you’re done, be sure to click “No” to resume the full compile. Don’t click “Yes” because then the compilation will not resume and you’ll have to start again.

  • Next Page »

     

Wordpress // Photon theme // Copyright © Klaas Deforche