str2Enum Function
Dynamics AX 2009
Converts a localized string into one of the integer values of the specified enumeration type.
enum str2Enum(enum _type, str _text)
The following example shows the appropriate way to use the str2enum function with the enum2str function. When your code inputs a string representation of an enumeration value into the str2enum function, that string should come from a call to the enum2str function that occurs on the same Microsoft Dynamics AX system. This prevents a mismatch between languages.
static void str2EnumAcrossLangs(Args _arg)
{
BankAccountType bat;
str sEnumValueNameLocalized;
int nInt;
;
sEnumValueNameLocalized = enum2str
(BankAccountType::SavingsAccount);
info("Localized friendly string: "
+ sEnumValueNameLocalized);
nInt = str2Enum(bat, sEnumValueNameLocalized);
info("nInt = " + int2str(nInt));
/********** Actual Infolog output
Message (04:32:09 pm)
Localized friendly string: Savings account
nInt = 1
**********/
}
Community Additions
ADD
Show: