Thursday, July 20, 2017

The text for the following task was not found: 0x0000, 0x0135 - when you run AX 2012 R3 client

If you have managed somehow to install an AX 2012 R3 client on the same host where you already have an AX 2012 R2 client installed, then you might encounter this error during R3 client startup:
The text for the following task was not found:
0x0000 , 0x0135 ,
This could be due to an error or an outdated version of the kernel text file.
This error can occure if in the default path (%ProgramFiles(x86)%\Microsoft Dynamics AX\60\Client\Bin) you have an AX 2012 R2 client installed. Then the AX 2012 R3 client might use the R2 ktd-files and it can't find one item there. Here's what you can do:

  • Open %ProgramFiles(x86)%\Microsoft Dynamics AX\60\Client\Bin\AxSys[YourLanguageId].ktd in a text editor - it will be the R2 ktd-file.
  • Find ">MSGID_TASKTEXTS5" without quotes.
  • After "0x1231 DropDialog" append the following line and save the changes:

0x0135 Microsoft Dynamics Lifecycle Services | Microsoft Dynamics Lifecycle Services


Sunday, June 05, 2016

Windows Installer error 1603 when installing a kernel hotfix and error 1325 'globalassemblycache' is not a valid short file name

Here's my case: a test VM provided by a system administrator, system partition C:\ and an extra partition D:\ for working files, backups, etc. Several Dynamics AX instances installed and running, AX kernel has been successfully updated a couple of times. Then a system administrator decided to add a virtual CD drive as D:\ and changed the extra partition drive letter to E:\ - rather disturbing but not a big deal, I thought.
After a while I need to apply a recent AX kernel hotfix - but Windows Installer fails with error 1603 while applying the AOS kernel patch. In the verbose log there's also another error during the CostFinalize action:
Error 1325. 'globalassemblycache' is not a valid short file name.
This error is logged after adding lots of properties that map to subfolders of E:\globalassemblycache\. According to the KB834484 error 1603 means Windows Installer can't access the product folder or something. That is a clue because one of the properties, DirGAC.Blah-Blah-Blah, is logged to be set to D:\globalassemblycache, and in my case D:\ is a virtual CD drive with no image mounted.
I had changed the CD drive letter and the AX kernel hotfix installed successfully. Then I reverted the CD drive letter back - just in case.
The point is: in case of Windows Installer error 1603 look carefully for suspicious paths in the verbose log.

Friday, January 16, 2015

X++ types Date and UtcDateTime are not implicitly converted to System.DateTime in .NET CIL, in AX 2012

Consider the following code sample:
System.Web.HttpCookie   cookie  = new System.Web.HttpCookie('test');
date                    dateVar = today() + 1;
cookie.set_Expires(dateVar);
It's just a .NET class object with a property of System.DateTime type initialized by a value of X++ date type. This code works perfectly in X++, but in .NET CIL it raises System.NotSupportedException with a message DateTimeConverter cannot convert from Microsoft.Dynamics.Ax.Xpp.AxShared.Date (or DateTimeConverter cannot convert from Microsoft.Dynamics.Ax.Xpp.AxShared.utcdatetime in case of X++ utcDateTime type).
According to MSDN article How to: Marshal Between X++ and CLR Primitive Types [AX 2012]
in Microsoft Dynamics AX, the X++ language does implicit conversion or marshaling between several X++ primitive types and their counterpart types managed by the common language runtime (CLR).
such as dateSystem.DateTime conversion. Well, in fact it does utcDateTimeSystem.DateTime conversion, too! But when X++ code runs in .NET CIL you have to explicitly convert values between date/utcDateTime types and System.DateTime. And actually you should do that anyway ‐ just in case your code happens to run in .NET CIL, otherwise you'll get System.NotSupportedException when you least expect it...

Saturday, September 27, 2014

X++ Operators Div and Mod Behave Differently in .NET CIL, in AX 2012

X++ operators div and mod in CIL can cast their operands differently and return result of different base types compared to X++ interpreter. Consider these examples:
Test operationX++ resultsCIL results
0 div 2Integer0Int640
intMax() div 2Integer1073741823Int641073741823
realMax() div 2Integer1073741823Int644999999999999999
int64Max() div 2Int644611686018427387903Int644611686018427387903
intMax() mod 2Integer1Integer1
realMax() mod 2Integer1Real1,00
int64Max() mod 2Int641Int641

Tested in AX 2012 R2 with kernel builds 6.2.1000.4051 (CU7) and 6.2.1000.8310.

Tuesday, June 10, 2014

AX 2012: don't party with deleted PurchLines

In previous version of Dynamics AX if you delete a PurchLine record - it's gone from the table; it means that for a given purchase order you've got only "active" actual PurchLine records in the database table. AX 2012 has introduced a lot of new and enhanced Procurement and sourcing features including Change management for purchase orders. From a developer's perspective it means that PurchLine records are no longer deleted - instead they are marked with IsDeleted flag and filtered out on regular forms (obviously except for Purchase order versions form). So in customizations it's now vital to mind that and to select or update only PurchLine records with IsDeleted == NoYes::No predicate in the where clause. PurchTable.queryPurchLine() can provide you with a query that takes this into account.

Friday, May 02, 2014

Best Practice checks for objects in the current layer only in AX 2012

It took a small customization to make Best Practice checks in AX 2009 to omit application objects that are not present in the current application layer, which really makes a difference in terms of compilation speed. In AX 2012 you have this feature out of the box! In the development environment navigate to Tools > Options > Development > Best Practices and change the Layer setting to "Skip nodes from lower layers".

Thursday, September 01, 2011

Script to recreate SqlDictionary records in AX 2009

Here's a script that can recreate SqlDictionary records in AX 2009 for any field of (nonsystem) table - in case such record is missing for some reason while the field exists in the database. I used this script during an upgrade to AX 2009 last year. Some fields in the standard application got the same IDs as fields added during customizations and they had different base types, of course, and it seemed impossible to fix the situation using standard means. The script might be of interest to those who wants to know the relations between the SqlDictionary and the AOT.
#macrolib.DictField
// This type is used instead of Types::Int64 for fields of type
// RecId/RefRecId/createdTransactionId/modifiedTransactionId
#define.RecIdBaseType   (49)
// For nonsystem fields of type UtcDateTime an additional field is created
// that holds the actual time zone in which the value has been set
#define.TZIDsuffix      ('_TZID')          

SqlDictionary   sqlDict;
SysdictType     dictType;
DictTable       dictTable;
DictField       dictField;
ArrayIdx        arrIdx;
Counter         numOfSqlFields; // number of records created in SqlDictionary
fieldName       fieldName;
fieldId         fieldId;
tableId         tableId = tablenum(TheTable2Fix);  // TARGET

boolean processTableField(
    DictField   _dictField,
    ArrayIdx    _arrIdx,
    boolean     _isTzIdField = false
    )
{
    ArrayIdx    dictArrIdx;
    str         infoName;       // this field name is for messages only
    FieldName   sqlName;
    boolean     ret;
    ;
    if (_isTzIdField)
    {
        if (    _dictField.baseType()   != Types::UtcDateTime
            ||  _dictField.id()         == fieldnum(Common, createdDateTime)
            ||  _dictField.id()         == fieldnum(Common, modifiedDateTime)
           )
        {
            throw error(Error::wrongUseOfFunction(funcname()));
        }
        dictArrIdx  = _dictField.arraySize() + _arrIdx;
        sqlName     = _dictField.dateTimeTimeZoneRuleFieldName(_arrIdx - 1);
        infoName    = _dictField.name() + #TZIDsuffix;
    }
    else
    {
        dictArrIdx  = _arrIdx;
        sqlName     = _dictField.name(DbBackend::Sql, _arrIdx);
        infoName    = _dictField.name();
    }
    select firstonly sqlDict
        where   sqlDict.tabId   == _dictField.tableid()
            &&  sqlDict.fieldId == _dictField.id()
            &&  sqlDict.array   == dictArrIdx
                ;
    if (!sqlDict)
    {
        sqlDict.clear();
        sqlDict.initValue();
        sqlDict.tabId           = _dictField.tableid();
        sqlDict.fieldId         = _dictField.id();
        sqlDict.array           = dictArrIdx;
        sqlDict.name            = strupr(_dictField.name(DbBackend::Native, _arrIdx));
        sqlDict.sqlName         = sqlName;
        dictType                = new SysDictType(_dictField.typeId());
        if (_isTzIdField)
        {
            sqlDict.fieldType   = Types::Integer;
        }
        else
        if (        _dictField.id()     == fieldnum(Common, RecId)
            ||      _dictField.id()     == fieldnum(Common, createdTransactionId)
            ||      _dictField.id()     == fieldnum(Common, modifiedTransactionId)
            ||      _dictField.typeId() == extendedtypenum(RecId)
            ||      _dictField.typeId() == extendedtypenum(RefRecId)
            ||  (   dictType
                &&  dictType.isExtending(extendedtypenum(RecId))
                )
           )
        {
            // This type is used instead of Types::Int64 for fields of type
            // RecId/RefRecId/createdTransactionId/modifiedTransactionId
            sqlDict.fieldType   = #RecIdBaseType;
        }
        else
        {
            sqlDict.fieldType   = _dictField.baseType();
        }
        sqlDict.strSize         = _dictField.stringLen();
        sqlDict.shadow          = bitTest(_dictField.flags(), #DBF_SHADOW);
        sqlDict.rightJustify    = bitTest(_dictField.flags(), #DBF_RIGHT);
        sqlDict.flags           = sqlDict.shadow;   // not _dictField.flags() at all!
        sqlDict.nullable        =   _dictField.baseType() == Types::Container
                                ||  _dictField.baseType() == Types::VarString
                                    ;
        if (sqlDict.validateWrite())
        {
            sqlDict.insert();
            ret = true;
            info(strfmt(@"Created record for field %1.%2%3",
                        dictTable.name(), infoName,
                        _dictField.arraySize() > 1 ? strfmt(@"[%1]", _arrIdx) : ''));
            // for all nonsystem UtcDateTime fields we also create a related TZID-field
            if (   !_isTzIdField
                &&  _dictField.baseType()   == Types::UtcDateTime
                &&  _dictField.id()         != fieldnum(Common, createdDateTime)
                &&  _dictField.id()         != fieldnum(Common, modifiedDateTime)
               )
            {
                processTableField(_dictField, _arrIdx, true);
            }
        }
        else
        {
            ret = checkFailed(strfmt(@"%1 record for %2.%3 was not created",
                                     tablestr(SqlDictionary), dictTable.name(), infoName));
        }
    }
    return ret;
}
;
dictTable = new DictTable(tableId);
if (!dictTable)
{
    throw error(strfmt(@"Failed to create %1 for '%2' (%3)",
                classstr(DictTable), tableid2name(tableId), tableId));
}
if (dictTable.isSystemTable())
{
    throw error(strfmt(@"'%1' is a system table, no way...", dictTable.name()));
}
if (!dictTable.isSql())
{
    throw error(strfmt(@"Table '%1' should not be in DB", dictTable.name()));
}
for (fieldId = dictTable.fieldNext(0); fieldId; fieldId = dictTable.fieldNext(fieldId))
{
    dictField = dictTable.fieldObject(fieldId);
    if (dictField && dictField.isSql())
    {
        fieldName = dictField.name();
        for (arrIdx = 1; arrIdx <= dictField.arraySize(); arrIdx++)
        {
            numOfSqlFields++;
            processTableField(dictField, arrIdx);
        }
    }
}
select firstonly sqlDict
    where   sqlDict.tabId   == tableId
        &&  sqlDict.fieldId == 0
            ;
if (!sqlDict)
{
    sqlDict.clear();
    sqlDict.initValue();
    sqlDict.tabId       = tableId;
    sqlDict.name        = strupr(dictTable.name());
    sqlDict.sqlName     = dictTable.name(DbBackend::Sql);
    sqlDict.strSize     = numOfSqlFields;       // for the table "header" - num of fields 
    sqlDict.flags       = dictTable.isView();   // that's the way it is
    sqlDict.insert();
    info(strfmt(@"Created record for table %1", dictTable.name()));
}