Tuesday, January 11, 2011

How to create a 'Do not tell me again' info box

In AX, there is an Ok/Cancel box that can pop up to the user but have the option to allow the user to not be shown that popup in the future. An example of this would be opening the User's Options within AX.
This feature could be used for something like providing valuable tips to the user when they first log into AX or a form/module.
This is easily accomplished using AX's Box function:
Box::okCancelOnceModal(_captionStr, _headerStr, _infoStr, _ownerStr)
This call does not return a DialogButton enum like the other OkCancel prompts. It will instead return a boolean.
//Sample Code
if (this.checkUserQueryCriteria)
     return Box::okCancelOnceModal('Checking query','@SYS70764', 'This could take a while...', 'Fun Times Example');
     return true;


  • _captionStr - The text that appears at the very top of the dialog box. This could be something like 'Did you know that...' in the example of providing useful tips to the users. Or informating them that a feature has changed in a new version of something.

  • _headerStr - The text that appears just to the right of the 'Info' bubble in the white section of the pop up window.

  • _infoStr - The text that appears just above the 'Do not show this again' text.

  • _ownerStr - this is the text that will appear in the Usage Data's 'More info...' field with a 'System name' field value of BoxinfoOnce.

    USERFUL TIP: You can access the usage data by going to the Options form (Dynamics AX Menu -> Tools -> 'Options'), then clicked the 'Usage data' button. Under here, find the appropriate place where the call is located. In AX 2009, it is under the 'Jobs' tab with a 'System name' of 'BoxInfoOnce'. Yours will be the one with the 'More Info' you put in the string (in my code example it is 'Fun Times Example'). By highlighting the record, you can delete it so that it will prompt the user again.

  • /*-------------!UPDATE!-------------*/
    I was recently asked 'Why would you use this?'. Fair question. There are many reasons but I'll cover two common ones.

    Scenario 1: Let's assume that we are prompting a user with a query where they will enter criteria. They have the possibility of making the returned results considerably larger than they intended. We could do some kind of validation on the input (like check for a range) and if it meets some kind of criteria, prompt the user letting them know that the result set could be very large and would they like to continue. To some, this would be a great check they would like to consistently be reminded of. To others, it is one more click. Using this box would allow both parties to be happy.

    Scenerio 2: You want to provide the user with helpful hints or information upon opening something. It may be a little 'Welcome' introduction or revolving tips that change over time that people may not want to see again. Its not for us to decide so we give the users the option to skip it.

    Monday, January 10, 2011

    Using UTCDateTime Variables in Select Statements

    Sometimes, you need to be able to compare a date with a UTC Date Time variable. This is how you use it in a select statement. This statement looks for sales table records that were created on 12/7/2010.
    The trick to this is that the function dateToBeginUTCDateTime() is not visible to the users through the normal right click method finding technique. You just have to remember what it is and know how to use it. I always forget the name so this is my personal reminder for the next time I inevitably forget.

    SalesTable salesTable;
    Date daxDate = str2date('12/7/2010', 2);
    TimeZone daxTimeZone = DateTimeUtil::getUserPreferredTimeZone();
    UTCDateTime daxDateTime = dateToBeginUTCDateTime(daxDate,daxTimeZone);
    while select salesTable
         where salesTable.createdDateTime == daxDateTime
         info (strFmt("%1 - %2", salesTable.SalesId, salesTable.CustAccount));

    or, you can replace the daxDateTime variable with a one-liner like this: