Search code examples
enumsaxaptax++dynamics-ax-2012

How to initialize the enum Field in a Table?


I have two Table, TableA , TableB. In TableA I have FieldA (EnumType-Noyes) , and the same I have in TableB.

I wanto to initialize with initValue method the value for the fieldA, but I have an error.

I used this code:

public void initValue()
{
 TableB tableb;
 this.fieldA = tableb.fieldb; //but can't assing
}

In my TableB , the field value (Enum NoYes) is Yes , but in debug i "read" the value NO.

I have to use a find methot for the return this parameter? Can help me?

Thanks,

enjoy!


Solution

  • You have only declared TableB in the initValue() method and have not initialized it with any record.

    This is basically the difference between: Class1 class1 and Class1 class1 = new Class1().

    So you need to do:

    TableB tableb = TableB::find('SearchArgument');
    if (tableb)
        this.fieldA = tableb.fieldb;