Posts

Showing posts from 2014

Dynamics AX - Enumerate subclasses of a specific class

A colleague of mine recently asked me if there was a quick way to find all of the classes that extend a certain base class. "But of course there is!" I said.  Here is the code block I sent him, should you, dear reader, need to accomplish a similar task. static void getSubclasses() {     List            subclassList;     ListEnumerator  listEnumerator;     SysDictClass    dictClass;     dictClass       = new SysDictClass(classNum(ExchangeRateProvider)); //Your class here     subclassList    = dictClass.extendedBy();     if (subclassList.elements())     {         listEnumerator = subclassList.getEnumerator();         setprefix(strfmt("%1 is extended by %2 subclasses", dictClass.name(), int2str(subclassList.elements())));         while (listEnumerator.moveNext())         {             info(ClassId2Name(listEnumerator.current()));         }     }     else     {         info(strfmt("%1 is not subclassed", dictClass.name()));     } }

Dynamics AX - A-Job Actions not being generated for a Channel after restoring databases

A fter restoring the model and data databases in AX, the A-Jobs that were working on the environment I migrated from and were not working on the new environment. Specifically, actions were not being generated for the store I was using for the preaction of changing a released product's discount flag (retail fast-tab). Turns out, it's the distribution locations (Retail -> Setup -> Retail Scheduler -> Distribution Locations) that were cached in the Global Object Cache not matching.  Deleting and re-creating the distribution locations fixed the issue. I suspect also clearing the global object cache would have done the trick. See: http://msdn.microsoft.com/en-us/library/hh608239.aspx

Dynamics AX: Remove Empty Code Block Warnings

A X is very picky about having SOMETHING to do inside of a code block.  For example, the compiler will issue the warning "Empty compound statement." when compiling the following code: boolean bob; try {      //fancy code here } catch { } //warning here If you want to suppress this error, you can call Global::exceptionTextFallThrough() method.  This method does absolutely nothing (right click and go to definition to see for yourself), but it does satisfy the compiler enough to remove the warning. boolean bob; try {      //fancy code here } catch {      //This does nothing but suppress the warning       Global::exceptionTextFallThrough(); }