Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Tuesday, September 6, 2011

enum2str Declaration in Microsoft Dynamics AX X++

To get the label for one specific enum value, simply use the enum2str function as shown in the next example:

static void Datatypes_enum2str(Args _args)
{
SalesType salesType; // a standard enum in Ax
;
salesType = SalesType::Sales;
info(strfmt("The name of the current sales-type is '%1'",
enum2str(salesType)));
}

Actually, in the previous example, you don't have to use the enum2str as the enum value is automatically converted to a str as it is used in a strfmt() function. However, trying to use the enum variable directly in the info will result in a compilation error because you cannot add an enum variable to a string. Hence, in this example the enum2str method would come in handy.

info("The name of the current sales type is " + salesType);

No comments:

Post a Comment

Archives