April 06, 2013

UTC DateTime Null Value in Ax

UTC DateTime Null Value in Ax

Some times we need to pass or check null value in UTCDateTime field.
so here is the logic to pass null value in UTCDateTime,

just try utcdatetimenull() function in your code, it will return the same value as 

DateTimeUtil::minValue() function.

In X++ The utcdatetimenull() value is '1900-01-01T00:00:00'.

-Harry

April 04, 2013

Finding unused lables

Finding unused labels in Axapta

Here is a small job for finding labels, from a particular label file, that are not used in your whole application code. You need an updated cross reference to use the job. I assumed that you are familiar with label files.


static void findUnXedLabels(SysOperationProgress _progress = null)
{
    Label     label       = new Label('da');// The languageto use for finding the labels
    str 250   labelId     = label.searchFirst('');
    Map       mapLabels   = new Map(types::String, types::String);
    MapEnumerator   mapEnumerator;
    ;

    setPrefix("Finding UnX'ed labels");

    while (labelId)
    {
        if (label.moduleId(labelId) == "XYZ") // The particular label file
        {
            if ((select xRefNames
                     index hint Name
                     where  xRefNames.Kind == xRefKind::Label &&
                            xRefNames.Name == labelId &&
                            xRefNames.TypeName == '').RecId == 0)
            {
                mapLabels.insert(labelId, label.extractString(labelId));
            }
        }
        labelId = label.searchNext();
    }

    // The maps is used to sort the lables
    mapEnumerator = mapLabels.getEnumerator();

    while (mapEnumerator.moveNext())
    {
        info (strFmt("%1 %2", mapEnumerator.currentKey(), mapEnumerator.currentValue()));
    }
}

In standard AX you can run this check for all labelfiles and save the result to a file, by using the \Classes\SysApplCheck\findUnXedLabels method.
-Harry