Code highlighting

Friday, May 09, 2014

Walkthrough: Fixing error "Incorrect Mobile device display settings..." on the mobile device when trying to sign in

All the people who have tried the new Warehouse management mobile solution by now have probably hit the issue below and were confused about the error message displayed, as well as how to fix this.

The scenario is simple:

1. Install and Configure the Warehouse Mobile Device Portal through setup.exe.
As part of this step, you will need to specify a domain account to use as the identity of the IIS application pool that is used to run the Warehouse Mobile Device Portal (WMDP in short).

Warehouse Mobile Device Portal Installation Wizard

2. Completing the installation process will create a site in IIS. You can access this site, and it will open the WMDP home screen. If you now click on Log on to the mobile device, you will get the below error, if the domain account from the IIS app pool is not added as a user in Dynamics AX, or if he does not have sufficient privileges to run the mobile device portal.

WMDP error - insufficient privileges to connect to AX

3. After adding the user to AX and assigning the appropriate roles to him, you can try logging on to the mobile device again. Now, you might get a different error, like below

WMDP error - display settings are not configured

If you read the error message, you can see it complains about the mobile device display settings not being configured. Well, let's check them out, under Warehouse management > Setup > Mobile device > Work user mobile device display settings
As you can see on the below screenshot, I have them defined, and the setup is valid. Hmm, what is the above error about then?

Work user mobile device display settings

Root cause:
The problem is actually with the default company set for the above AX user. By default the portal tries to connect to the company set as the default for that user, and thus cannot find the display settings, since they are created per company and don't exist in DAT (most probably).

4. After assigning a valid default company to the AX user, the domain account of which is running the IIS app pool for WMDP, we can try logging on to the mobile device portal again. Now we can see that we reach the Sign in screen, which means all is good in the world. :)

Warehouse Mobile Device Portal Sign In page

Hope that helps avoid initial confusion when trying to use the mobile device portal!

Walkthrough: After setting up a work-related Mobile Device menu item the user is constantly logged off when trying to use it on the device

Hey guys

As some of you might know, I was part of the team that released the new Warehouse and Transportation solution as part of Microsoft Dynamics AX 2012 R3.

As with any first version of the product (and this is a huge solution), there are certain issues that we simply did not have time to address. Some of them are however pretty hard to figure out the root cause for, unless you spend time debugging or know where to look to start with.

When setting up Mobile Device menu items to use at the warehouse, you have a couple of possibilities for what type of menu item it is going to be. Specifically, it can be a non-work related activity, a work-related activity, which results in creation of new work, or processing of existing work.

I won't go into the full description of how to set this up - you can easily find this information on technet, MSDN, etc.

Here's the short version of the flow, and the problem you might experience.

  1. Navigate to Warehouse management > Setup > Mobile Devices > Mobile device menu items
  2. Create a new menu item, and fill in the fields. Select Mode = Work, Use Existing Work = false.
  3. Select Work creation process = Load item receiving
  4. Save the record. It should look like below
  5. Add the created menu item to one of the available mobile device menus.
  6. Log in to the mobile device with any available work user and navigate to the menu item created above.
Mobile device menu item
The created Mobile device menu item

Possible result of executing the above steps:
Sometimes, without any explanation, the user is consistently logged out of the mobile device, when trying to use the newly created menu item.

Root cause:
The problem can be that when creating the menu item, you accidentally selected an Activity code, changing its value from None to the next value on the list, which is Log off. This can happen quite easily, especially if you normally use the keyboard and not the mouse to click around. 
Now, even though you later changed the Mode to Work, the system still remembers the selection in the Activity code, and will apply it when using the menu item, resulting in a log off.

That's quite annoying, but also very easy to fix, just flip Mode to Indirect, revert the Activity code value back to None, and flip the Mode back to Work. All your settings for work creation setup should stay intact. 

To finish off, I just want to encourage all of you to install Dynamics AX R3 and try out the new modules, and send us feedback through Connect, Yammer, or comments on the SCM blog or here.


Monday, May 05, 2014

Q&A session: Working with UtcDateTime from X++

There were a couple questions asked in the post I wrote a while back about the use of UtcDateTime in AX.

Question 1:
Hi. how can put date in a field utcdatetime?

The method newDateTime from class DateTimeUtil can be used to accomplish this, as it takes the date and time parts in separately as arguments, followed by the TimeZone enumeration in case a timezone offset needs to be factored in. Otherwise the UTC timezone will be used.

static void CreateUtcDateTimeFromDate(Args _args)
    date locDate = mkDate(5, 3, 2014);

    info(strFmt("Date converted to DateTime, with 0 for time and no timezone offset = %1",
        DateTimeUtil::newDateTime(locDate, 0)));

The result of executing this job would look like below:

Date converted to DateTime, with 0 for time and no timezone offset = 3/5/2014 12:00:00 am

Question 2:
Hi...Can you please tell the difference between UtcNow() and getSystemDateTime(). Both are returning GMT time only. But where as in msdn they described differently...

The difference is you can "fix" the systemDateTime either through the API (DateTimeUtil::setSystemDateTime()) or through the Tools in the Dynamics menu, as shown on the screenshot:

Dynamics AX session date and time
Session date and time dialog

static void DifferenceBetweenUtcNowAndSystem(Args _args)
    info(strFmt("getSystemDateTime = %1", DateTimeUtil::getSystemDateTime()));
    info(strFmt("utcNow = %1", DateTimeUtil::utcNow()));

So, after having fixed the system datetime, the output from executing this job would be like below:

Info Message (11:01:28 pm) getSystemDateTime = 5/1/2014 12:00:00 am
Info Message (11:01:28 pm) utcNow = 5/5/2014 09:01:28 pm

If the system date time is not fixed, it will return the local system datetime, pretty much like utcnow.

Note, that msdn actually also describes a slight difference in how utcnow works - it seems it always runs on the server, so always returns the AOS datetime. I can't test it right now because only have a dev.setup with everything on 1 box. Once I get a 3box one, I will update this post with a confirmation.

Q&A session: Working with MorphX project nodes from code

I had some spare time today, so started answering some of the comments I had through the blog and through e-mail. I decided I'll just open up a new section on my blog, called Questions and Answers, in which I will slowly answer the questions from my backlog:

Question (related to post about the DEV_CreateNewProject tool for AX):
So could create ConfigKeys Macro and I wanted, and could throw them into the project that was created, but I can not throw them within their respective nodes, so they are loose in the project, you can help me put them within your nodes?

To summarize, Gustavo wanted to create some AOT elements from code (specifically, configuration keys and macros), and add them to a new project into respective groups, similar to how it is done in DEV_CreateNewProject tool.

I wrote a small job that does that, and can be downloaded from my OneDrive. The code is also pasted and explained below:

static void Tutorial_CreateProjWithGroupAndElement(Args _args)
    ProjectListNode     treeNodeProject;
    ProjectNode         upgradeNode;
    ProjectGroupNode    child;
    MacroBuild          macro;

    str projName = @"Project01";
    str groupName = @"macroGrp";
    str macroName = @"macro01";

    treeNodeProject = SysTreeNode::getPrivateProject();
    upgradeNode = treeNodeProject.AOTfindChild(projName);
    upgradeNode = upgradeNode.getRunNode();

    child = upgradeNode.AOTfindChild(groupName);

    macro = new MacroBuild(macroName, true);

    child.addUtilNode(UtilElementType::Macro, macroName);


  • SysTreeNode class is used to retrieve the object for the root of the Private projects node. This class contains a number of interesting methods for anyone who wants to navigate and manage AOT nodes
  • Standard AOTadd and AOTfindChild methods are used for first creating and then loading the contents of the node into a TreeNode object for processing.
  • getRunNode is used on the project node so that it is not just loaded for processing, but also opened in a new window to show the result to us after executing the job
  • MacroBuild class is used to creating new Macros, and is similar to a ClassBuild that I described previously
  • addUtilNode is the key method Gustavo was missing, and allows to add the macro created to the project group node. 
  • AOTsave() is used to persist all the changes done to the project as well as the new macro.

You can see the results immediately after executing the job.