Saturday, June 12, 2010

Using .NET enum in X++

With the CLRInterop feature, you can easily write X++ codes that instantiate and call .NET classes. One of the limitation in IntelliSense is it does not support auto displaying the .NET enumeration value. Luckily there is a useful method called ClrInterop::parseClrEnum(_clrEnumTypeName, _enumValues), which you can convert a string of the .NET enum value to a CLRInterop object.

Example of the usage:-
System.Net.Mail.MailMessage             mailMessage;
System.Net.Mail.DeliveryNotificationOptions deliveryOptions; //.NET enum
deliveryOptions = ClrInterop::parseClrEnum('System.Net.Mail.DeliveryNotificationOptions', 'OnSuccess');

No comments: