سؤال

I am trying to understand how to access dynamics enums to be able to pass these into BusinessConnector calls. For instance, you can call the following:

pobj = (AxaptaObject)ax.CreateAxaptaObject("PurchFormLetter", [ENUM]);

But, I have no idea how to pass in the correct value of [ENUM]. In X++, the enum is DocumentStatus::PurchaseOrder, but I don't seem to be able to access this from anywhere. Can anyone possibly assist in finding out how to pass in the value?

Passing in the numeric value of the enum does not work unfortunately (in this case the value I need is 2). It returns an XPPException of 'Function PurchQuantity::construct has been used incorrectly.'

AxaptaObject pobj = (AxaptaObject)ax.CreateAxaptaObject("PurchFormLetter", 2);

If anyone could please be of assistance that would be greatly appreciated.

Regards, Steve

هل كانت مفيدة؟

المحلول 2

Ok, this is for everyone else who hits this problem:

If you want to access the enum values from .NET purely without using X++:

string enumName = "DocumentStatus", enumValue = "PurchaseOrder";
object enumObj = (int)axa.CallStaticClassMethod("Global", "enumName2Id", enumName);
AxaptaObject dict = (AxaptaObject)axa.CreateAxaptaObject("DictEnum", enumObj);
object res = dict.Call("symbol2Value", enumValue);

The above can be made into a function very easily if reuse is required.

Still, doing the following won't work:

AxaptaObject pur = (AxaptaObject)axa.CreateAxaptaObject("PurchFormLetter", res);

However, you can do it this way:

AxaptaObject pur = (AxaptaObject)axa.CallStaticClassMethod("PurchFormLetter", "construct", res);

This will allow you to pass in the integer value of the enum (in this case, the variable 'res'). You can then use this object to post the purchase order.

Hope this helps someone.

Regards, Steve

نصائح أخرى

Others have the same problem. And they have found a solution by creating an enum proxy.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top