enum value import into ax


dir.Type= str2enum(COMVariant2Str(cells.item(row, 2).value());

Type field is a enum, I’m trying to import the value from excel into ax DirpartyTable.

How should i convert this field into enum value?

Thanks in advance.

If your question is how to convert a string the enum, please tell us what string you’re talking about. We don’t have the rest of your code nor your Excel file, so we clearly can’t know what value you’re getting from cells.item(row, 2).value(). It’s up to you to give is this information.


This type field is of enum type, when i tried to import this field i need to know how to mention this enum field in code…

No, I wanted to know what you get in your code. You may have a bug even before the conversion.

But now I see you have two compilation errors on the single line of code. Namely, there is one closing parenthesis missing and you’re missing the one parameter of str2enum().
Either you gave us some other code that you actually use, or you’re ignoring compilation errors (!).
Please make sure you fix these errors first.

dir.Type= str2enum(COMVariant2Str(cells.item(row, 2).value()));

error is- The wrong number of arguments has been specified for the function…

similarly i tried to convert the Gender value from excel into ax using this code emp.EmplGender=str2enum(cells.item(row,3).value().bStr());

I got the same error again.

Try this,
dir.Type = new DictEnum(enumNum(DirPartyType)).name2Value(cells.item(row,2).value().bStr()) ;