Wednesday, June 26, 2013

How To: Pass a container via args.parm() functionality

In AX 2012 (and previous versions), there is something called an args() which is short for arguments. It primarily comes into play where an object (like a form) opens up another object.

From MSDN:
"The Args class is used to pass arguments such as a name, a caller, and parameters between application objects."

For example, if a form opens up from another form (think ListPage form to non-list page), information about that first form can be passed to the second form that is being opened. Usually this is data like what form the second form is being opened from, any special data parameters, etc.

Anyways, with that prefacing out of the way...

NOTE: Italics below indicate an update to the original post. I think it will make more sense to what the post is showing.

The Problem: There is a requirement to pass a container from one form to another form and we cannot use args.parmObject() functionality as its already taken. For this example, we are trying to pass a set of record Ids. While containers can have other values, we're just going to use recIds so I can show a few other features.

The Issue: There is no way to pass a container through other means. There are options to pass a string, enum, record set, static string value, or object instance, but no container. The parmObject instance is unavailable but args.parm() which only takes a string and is available.

The Resolution: Here is how it was solved:
  1. Take the container and convert it a string with commas separating the variables
  2. Pass the string to the args().parm() call in the first object
  3. Retrieve the string from args().parm() in the second object
  4. Convert the string to a container
For point 1, we need to use the con2str function. con2str(container c [, str sep] ).  For example, "con2Str(conRecIds,',')" would convert the container into a string using a comma as a separator.

For point 4, we need to use the str2con function. str2con(str_value [, str 10 _sep, boolean _convertNumericToInt64] ).  For an example, "str2con(strRecIds, ',', true)" would convert a string with commas as what distinguishes the individual components. The third parameter '_convertNumericToInt64' is really handy. It will take the string values and auto-convert them to an int64 (e.g. recId) when set to true.

Some code example:

[Action: Highlighted a few records and clicked a button]
container conRecIds;
str       strRecIds;

tmpTable = dataSource_DS.getFirst(1); 

while (tmpTable.RecId != 0)
   conRecIds += int642str(tmpTable.omRecID);
   tmpTable = dataSource_DS.getNext();

strRecIds = con2Str(conRecIds, ',');

container conRecIds;
str       strRecIds;

strRecIds = args.parm();
conRecIds = str2con(strRecIds, ',', true);

Monday, June 10, 2013

AX 2012 for Retail - Cursor on POS is hidden behind POS program

Issue: A common 'issue' people will see within the AX 2012 for Retail POS is that the mouse cursor will be stuck behind the POS screen. It moves around the desktop ok but the mouse won't be on top of the actual POS window. This can create an issue if the user of the POS doesn't have a touchscreen monitor.

Solution: Under the terminals visual profile (AX->Retail->Setup->POS->Profiles->'Visual profiles'), there is a check box called 'Hide cursor' (See Figure 1 below). If this is checked, the mouse will not appear on top of the program. If it is unchecked, it will act like any other normal program on your desktop. Make sure to determine if making this change is really what you want to do. Reminder: Once a change is made, make sure to run the appropriate job to get the changes reflected in the POS (in base, N-1070, or A-1070 when actions run).

Reason Why: Most POS solutions are designed to be touch screen. In touch screen solutions, having a cursor on the screen is unnecessary and can create issues. This feature essentially tells the destination POS it will be going into 'touchscreen mode'. This doesn't affect any functionality other than the mouse not appearing on top of the POS application.

 Figure 1- The 'Hide cursor' check box

Thursday, June 6, 2013

Proper way to use acronyms in a conversation, email, or article (e.g. blog post)

It's a pet peeve of mine when you interact with someone who is a subject matter expert (SME) and will carry the assumption that you know what a certain acronym means. This is a pretty bad assumption to have as its wrong a good portion of the time and only creates confusion.

It should always be best practice to start with the entire spelled out words followed by the abbreviations in parenthesis the first time the acronym is used. From that point on, you can refer to the acronym in the parenthesis in the

Without proper context the first time the acronym is used, you may have people interpret what it stands for incorrectly. This will create a disconnect and, if one exists, you are probably wasting your time and theirs.

Remember that acronyms can mean more than one thing especially in a certain subject. For instance, SME can mean Subject Matter Expert or Small and Medium-sized Enterprises. For an AX example, DMF can mean Intelligent Data Management Framework (casually called data management framework) or Data Migration Framework (now re-branded Data Import/Export Framework [DIEF]). You can see how confusing this can get.  

Doing this might seem like a pain up front but it's kinda like flossing. Definitely a pain in the ass (PITA) to get in the habit of initially but once you become used to it, it saves you a lot of pain down the road.

Monday, June 3, 2013

What do the terms '-ve' and '+ve' mean?

What do '-ve' and '+ve' mean? I was seeing this in reference to accounting terms and working with India offshore teams. I wasn't able to find anything online about it so hopefully this will help people out.

As it was explained to me, this is a cultural short hand for negative (-ve) and positive (+ve) values in India. Almost an emoticon like 'lol' or a smiley face.

Super short post but useful info. Enjoy!

Saturday, June 1, 2013

How many tables are there in AX 2012?

Sometimes people want to know how many tables exist in an AX environment. Since different environments can vary in regards to the number of tables there can be due to customizations and 3rd party software, I wrote a job you can copy and paste in a job and run. It should only take a second or two to run. Kinda fun. The environment I wrote this in had 5534.

In the code, you can modify the '\\' string to do something like count forms '\\Forms' or EDTs '\\Data Dictionary\\Extended Data Types'

I'm aware of the #TablesPath (in #AOT) being used instead of the '\\Data Dictionary\\Tables' string but I wanted to keep this example simple and straight forward.

static void daxCountTablesInAX(Args _args)
    // Count of all the forms.    
    info (strFmt("Tables in AX: %1", treenode::findNode('\\Data Dictionary\\Tables').AOTchildNodeCount()));    

Figure 1 - The infolog from the code above