Execute a job on data in several companies

  • April 29, 2010
  • 2 Comments

There is a verry simple trick to loop through some companies and execute some code in them. Just write: DataArea dataArea; ; while select dataArea where !dataArea.isVirtual { changecompany(dataArea.id) { // Do Something… } }DataArea dataArea; ; while select dataArea where !dataArea.isVirtual { changecompany(dataArea.id) { // Do Something… } } Note! Make sure that you … Continue Reading

Batch job performance boost

  • April 22, 2010
  • 0 Comments

Did you ever have trouble with the performance of your batch-job? Well maybe this small trick can shorten the time your batch runs. The big idea: Try to split up your gigantic batch in smaller pieces. Launch a batchjob that produces many smaller batchjobs (tasks) that can handle a subset of the data you need to … Continue Reading

Tip for overriding methods

  • April 19, 2010
  • 3 Comments

There is a simple and generic way to force overriding a method you created. To do so you just need create your new method and place a ‘throw error’ statement in it. To finish you can add the static method missingOverride from the error class and the funcName() to your error. Now when this method … Continue Reading

Expressions in query ranges – limitations

  • April 9, 2010
  • 2 Comments

When you want to construct a query-object that contains OR-conditions, you can construct something like this: 1 2 3 4 5 6 queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3) && (%4 == "%5")))’, fieldStr(InventTable, ItemType), any2int(ItemType::Service), any2int(ItemType::Item), fieldStr(InventTable, ProjCategoryId), queryValue("Spares")));queryBuildRange.value(strFmt(‘((%1 == %2) || ((%1 == %3) && (%4 == "%5")))’, fieldStr(InventTable, ItemType), any2int(ItemType::Service), any2int(ItemType::Item), fieldStr(InventTable, … Continue Reading

Test if a configuration key is enabled in X++ code

  • March 22, 2010
  • 0 Comments

How do you execute code when a Configuration key is enabled? It is pritty easy. Ax x++ has a build-in function ‘isConfigurationKeyEnabled’, witch you can use to check a configuration key. Small example: if (isConfigurationKeyEnabled(configurationkeynum(AIF))) { // Do something… }if (isConfigurationKeyEnabled(configurationkeynum(AIF))) { // Do something… }

Setting propperties on a FormControl without AutoDeclaration

  • March 19, 2010
  • 2 Comments

When you want to set a property of a control on a form without setting the property AutoDeclaration = yes. You can address the control trough the following code, knowing that element is a FormRun-object: element.design().controlName("btnOk").visible(false);element.design().controlName("btnOk").visible(false);

Create class from code

  • March 11, 2010
  • 0 Comments

Did you know that you can build/modify classes from code? It is actually not so hard, just use the ClassBuild-class. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 static void JeDoe_testClassBuild(Args _args) { ClassBuild classBuild; ClassNode classNode; Str myCode; ; myCode … Continue Reading

Catching a key-press

  • March 10, 2010
  • 1 Comment

When you want to catch a key-stroke on a form, you can override the method task() The default method will look like this: public int task(int _taskId) { int ret; ret = super(_taskId); // write you’re code here return ret; }public int task(int _taskId) { int ret; ret = super(_taskId); // write you’re code here … Continue Reading

strrep vs. strreplace

  • March 7, 2010
  • 0 Comments

In Ax the name of Methods are sometimes (by my opinion) not so clear chosen. For example, when I try to replace a string in ax by typing strrep(..) instead of strreplace(..). strrep –> repeat a certain string for X times. strreplace –> replace a certain string. So please chose clear names for your methods…

List of mandatory fields on a table

  • February 22, 2010
  • 0 Comments

When you want a list of all the mandatory field on table X, yould check all the properties on the table fields, or you could be lazy and write a small job that does the trick for you. Just replace TableId with your tablenum. 1 2 3 4 5 6 7 8 9 10 11 … Continue Reading