Tuesday, November 13, 2012

AX show container in infolog

There are times where you want to show a container in a window. For example, if you are implementing AX 2012 for Retail, you can send containers back to the POS.

For example, you may want to run a job in AX that mimics the retail transaction services (RTS) call that the POS is calling and see the raw data in AX thus totally eliminating the need for the POS in the testing process. I used this scenario in the below code using a dummy RTS method.

    Object      FormRun = classFactory.formRunClass(new Args(FormStr(SysConView)));
    FormDesign  design;
    Container   c; // The container we want to view


    if (!prmIsDefault('Caption'))
        design = formRun.design();

    // Use an RTS call and build/return a container using a customer id
    c = RetailTransactionService::containerExample('ARCA-000007');


The result from this code will look like:

Thursday, November 8, 2012

Formatting code into blogs

When pasting code into a blog post, there are a few ways that the information can be displayed. I've really done a consistent job of making the code readable.  This post will detail out two different ways that this can be reliably done. In order to format code, you will need to switch to the HTML editor portion of the blog as the other visual editing mode won't allow this.

Doing this style is preferable in my opinion as it looks clean and allows the user to scroll over to the code in case there are long lines that would normally bleed off the page or do a word wrap.

<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code> INSERT CODE HERE </code></pre>

The code above would look like the below:

Here is an example of it in action:

The below is useful if you want to use CSS for formatting code across multiple posts. The class attribute (using 'code' name) is mostly used to point to a class in a style sheet. However, it can also be used by a JavaScript (via the HTML DOM) to make changes to HTML elements with a specified class.

<pre class="code"><span style="font-size: x-small;">INSERT CODE HERE </span></pre>

The code above would look like the below:

Here is an example of it in action:

Tuesday, November 6, 2012

AX 2012 Find On Hand (Physical) Inventory By Date

Below is a quick way to return the On Hand (Physical) Inventory for an item and dimension value combination (variant and location in AX Retail term). Note that this is for on hand inventory, not ATP or anything. This method assumes that you are passing an item, an inventory dimension record, and a date.

  • _itemId - The Item Id for the item
  • _inventDim - The inventory dimension record for the item (variant)
  • _date - The date that we want to see the on hand inventory amount for

private Qty findOnHandByDate(ItemId _itemId, InventDim _inventDim, Date _date)
    InventDimParm    inventDimParmCrit;
    InventSumDateDim inventSumDateDim;

    // Set the dimensions
    inventSumDateDim = inventSumDateDim::newParameters(_date, _itemId, _inventDim, inventDimParmCrit);

    return InventSumDateDim.postedQty();