Monthly Archives: November 2007

Copy data between companies

I have recently done some modifications that required certain data that was very time demanding to enter manually in Dynamics Ax. This data was also needed in a number of different companies which meant that I had to enter this data several times.

Because I’m against all that is time consuming I created a script that only require that I enter my data once and then lets me copy this data to the other companies.
Continue reading Copy data between companies

Using CacheAddMethod

When working in forms and using display methods, sometimes they have a tendency to slow down the form to the degree that makes you wonder if it’s worth it at all. This is when cacheAddMethod comes in handy.

When using cacheAddMethod we place the method in memory, the effect of this is that the method only runs once when the form loads and then every time we switch between records. This instead of display methods normal behavior, which means it runs every time all the time.

For the cacheAddMethod to do what it’s supposed to we need it to run when the form starts up. If we have created the display method “OurTestMethod” on table SalesTable we want to place the call to cacheAddMethod in the init method on the form datasource SalesTable.
Continue reading Using CacheAddMethod

resAppl macro when using images

Using images in Dynamics AX can sometimes be a painful experience, just keeping track of the Integer that represents the images is almost impossible. But with a macro called resAppl this becomes much easier, mainly because you, most of the time, can guess what commands to use to get the image you want. This makes it easier to remember between times you are going to use it, and above all it makes your code much easier to read and follow.
Continue reading resAppl macro when using images

Find files in a file directory

If you want to open or read files in a file directory you can use the following example to find the filenames.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  static void showFileName(Args _args)
  {
      int           handle;
      FilePath      filePath;
      FileName      FileName;
      ;
 
      filepath = "c:\\windows";
 
      [handle,filename] = 
       WinAPI::findFirstFile(filepath + "\\*.*");
 
      while (filename != "")
      {
          info(filepath + "\\" + filename);
          filename = WinAPI::findNextFile(handle);
      }
 
      WinAPI::findClose(handle);
  }

Intercompany with buf2buf

When discussing the “Basics of changecompany” we copied table records from one company to another through X++ code. Using buf2buf makes this is a lot easier.

Buf2buf is used to copy one recordbuffer to another:

       buf2buf(Common _from, Common _to)

If we apply this to the code we used in “Basics of changecompany” we get:
Continue reading Intercompany with buf2buf

date2int is date2num

Let’s say you have two dates and want to know how many days there are between these two dates. Searching through Dynamics AX developers help you will find that there is an explicit conversion called date2int. This sounds reasonable, we do want to convert our date to an int to get the number of days.

But if you try to use date2int you will find that this will generate an error when compiling that says:

This function has not been declared

Obviously date2int does not work as the developer help suggests. But what does?
Continue reading date2int is date2num