Thursday, June 7, 2018

How to load all labels from a label file

Here is a small example of how to load all the labels of a particular label file, in a particular language. It takes about 6-8 seconds on my developer box to load the 122190 label from SYS.

public static void main(Args _args)
    info ("Starting");
    ClrObject labels = new ClrObject("System.Collections.Generic.Dictionary`2[System.String,System.String]");
    labels = Microsoft.Dynamics.Ax.Xpp.LabelHelper::GetAllLabels('SYS', System.Globalization.CultureInfo::CurrentCulture);

    ClrObject labelsEnumerator = labels.GetEnumerator();
        ClrObject keyValuePair = labelsEnumerator.get_Current();

        var currentlabelId = keyValuePair.get_Key();
        var currentTxt = keyValuePair.get_Value();
    info ("Done");