Normaly you try to avoid using AnyType variables, but sometimes you are forced to use them. When you use a AnyType enum and you want to cast it to it’s actual data type, be sure you cast it to the right type to prevent stack-traces. You can get the enumId from a AnyType-enum by using the DictEnum::value2id(AnyType _value) -function. Then you can compare it with the enumnum(EnumType) to check if it is the right type.
In code this check could look like this:
static void testAnyTypeEnumCasting(Args _args)
{
DocumentStatus docStatus;
Anytype any = DocumentStatus::Invoice;
;
switch (DictEnum::value2id(any))
{
case enumnum(DocumentStatus) :
docStatus = any;
break;
case enumnum(...) :
...
}
}
Subscribe to:
Post Comments (Atom)
How to identify the user that was used to change an object from AOT in AX2012
Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...
-
Combo boxes in Dialogs are added by adding a DialogField object with the type of an enum. The enum is then controlling what items you can pi...
-
This article explains: How to picking list through a job using X++ in Dynamics AX. Applied on: Dynamics AX 2009 SP1 Create a job a...
-
A while ago I had the need to translate labels, I was creating eMail bodys while using SysMailer and wanted to use different languages for d...
No comments:
Post a Comment