Thursday, 14 May 2009

Import csv job

Here is an import job for importing tuples from a csv file:

static void importJob(Args _args)
    FileIOPermission        permission;
    AsciiIo                 file;
    Filename                fileName = @"c:\test\test.csv";
    CustTable               custTable;
    container               line;
    permission  = new FileIOPermission(fileName, #read);
    file = new AsciiIo(fileName, #read);
    if(!file || file.status() != IO_Status::Ok)
        throw error(strFmt("@SYS76826", file));
    while(file.status() == IO_Status::Ok)
        line =;
        custTable.AccountNum = conPeek(line, 1);

Happy hacking

Saturday, 2 May 2009

Opening a form on start up of AX

I've recently implemented a variation of Palle Agermark's post on how to run a form on start up of AX. He opens a form through calling the Display menu item. I needed was to call a form with conditions, so I created a class which would handle the conditions in question and instead of calling the menu item I called the main method of the class

Thanks to GregP for his helpful tips and insisting that he could get it to work.

EDIT: There is a small aber dabei ( which roughly translates "there is a but", I just happen to like the German term better ). In order for the AutoRun to function, development rights for the user-group are necessary, as the function we utilize is typically used to automate installation/configuration. Giving the user group full development rights though is not an option in this scenario, so after some fiddling about I found that the only security setting the user group needs is SysLastMinuteCheck

which, by the way, only can be set giving the user group full development right and then removing all but this SysLastMinuteCheck.