viernes, 26 de junio de 2015

Find Menu Items that call Jobs

During an upgrade from AX 2009 SP1 to AX 2012 R3 it is reasonable to assume that the AOT\Job node can be disregarded from the upgrade process.  That is until you find various menu items that point (ObjectType property) to those Jobs that have not been converted!
Menu Items are 99% of the time for launching Forms, Classes or Reports.
The first task is to find those menu items, and then to analyse if it's necessary to convert them.  Are they still relevant?  Finally, shoot the developer that is creating all of these Jobs were they should be creating classes for a more accessible and repeatable solution.

Below is a job...  To look for a Job ObjectType in the MenuItem node of the AOT.

static void Job_MenuItem_Jobs(Args _args)
{
    // Use X++ to Loop through the AOT for Menu Items that call....  Jobs!
    // http://blogs.msdn.com/b/dsiebold/archive/2010/08/13/use-x-to-loop-through-the-aot.aspx
    // http://dynamicsuser.net/forums/p/29232/154476.aspx#154476
    MenuItem    mi;

    void searchSubNodes (TreeNode _treeNode)
    {
        if (!_treeNode)
            return;

        _treeNode = _treeNode.AOTfirstChild();
        while (_treeNode)
        {
            if (_treeNode.AOTfirstChild())
            {
                searchSubNodes(_treeNode);
            }

            if (_treeNode.applObjectType())
            {
                mi = _treeNode;
                if (mi.AOTgetProperty("ObjectType") == "Job")
                {
                    info(strfmt("%1", _treeNode.treeNodePath()));
                }
            }
            _treeNode = _treeNode.AOTnextSibling();
        }
    }
    ;

    searchSubNodes (TreeNode::findNode(@"\Menu Items"));

    info("End");
}

This migration is going to be a long one.

viernes, 5 de junio de 2015

Error in a Definition Group export: "Same version of Microsoft Office Excel must be used for export and import."

Error - "Same version of Microsoft Office Excel must be used for export and import."

Se debe utilizar la misma versión de Microsoft Office Excel para exportar e importar.
I recall receiving the file from a Client to be imported via Excel/Definition Group.  There exists a KB2830391 that fixes this one, should you wish to address the issue permanently.

To quickly and painlessly resolve this issue, however I found a comment in the AXUG forum immensely useful:
"In excel file, on #DEF sheet, please change Excel Version to Office 2000, (strange, but it helps)."

Therefore I'd recommend exporting the empty Definition group (set the Export Criteria to a value that does not exist) and open up the Excel spreadsheet '#DEF' worksheet.  Compare that to the one that you have and probably it will be 'Excel Version' - 'Office2000'.  Paste the value to your spreadsheet giving you problems, and you would probably need to Save As the file as 'Excel 97 - 2003 (*.xls)'.
'Office 2000' - The secret sauce.

EDIT: 17/06/2015 - Second error now, with possibly a similar issue with Excel Versions.  Error:
"Method 'value' in COM object of class 'Range' returned error code 0x80020005 (DISP_E_TYPEMISMATCH) which means: One or more of the arguments could not be coerced."

One time out of twenty the spreadsheet would start to import data but that's a terrible success rate that is unlikely to complete when attempting thousands of records.
If you can even get this far, fall to your knees and start praying.

Solution:   Simply creating a blank Excel spreadsheet with the 'correct' Excel version and recreating each Tab with the tab name and selecting all of the data to copy across each tab.  We successfully imported the new spreadsheet from the data in the previous Excel workbook...  Also going outside for a coffee and giving each other a big hug may have helped with this particular issue (Hint: Don't touch a thing in the desktop environment while importing).