Share via


any2Enum Function

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Converts an anytype value to the Name property value of an element in the target enum.

enum any2Enum(anytype object)

Parameters

Parameter

Description

object

The value to match the Value property of an element in the target enum.

Return Value

The value of the Name property for whichever element on the target enum has a Value property that matches the input parameter.

Remarks

The object parameter can be of most data types, but useful data is only obtained by using a parameter of type str or int.

This input object parameter refers to the Value property of an individual element in the target enum.

Example

    static void any2EnumExample(Args _args)
    {
        NoYes myNoYes;  // NoYes is an enum.
        int i;
        str s;
    
        i = 0;  // An int that will be converted.
        myNoYes = any2Enum(i);
        Global::info(strfmt("'%1' - is the output, from input of the %2 as int.", myNoYes, i));
    
        s = "1";  // A str that will be converted.
        myNoYes = any2Enum(s);
        Global::info(strfmt("'%1' - is the output, from input of the %2 as str.", myNoYes, s));
    
    /**** Infolog display.
    Message (01:05:32 pm)
    'No' - is the output, from input of the 0 as int.
    'Yes' - is the output, from input of the 1 as str.
    ****/
    }

See also

Enums

str2Enum Function

Announcements: To see known issues and recent fixes, use Issue search in Microsoft Dynamics Lifecycle Services (LCS).