Here is my code :
AxaptaObject dict = (AxaptaObject)DynAx.CallStaticClassMethod("Dictionary", "new");
object id = (object)dict.Call("enumName2Id", "TimeZone");
AxaptaObject dictEnum = (AxaptaObject)DynAx.CallStaticClassMethod("DictEnum", "new", id);
string s = (string)dictEnum.Call("index2Label", "2");
I am getting the following error:
Error executing code: Dictionary object not initialized.
Why is it throwing that error during initialization of Dictionary object? Kindly help.
Got it!
Code is as follows :
int enumId = (int)ax.CallStaticClassMethod("Global", "enumName2Id", enumName);
AxaptaObject dictEnum = (AxaptaObject)ax.CreateAxaptaObject("DictEnum", enumId);
return (string)dictEnum.Call("index2Label", index);
You have to use "AxaptaObj.CreateAxaptaObject". This way you can indirectly write X++ code in C# for small jobs such as these. I'm not sure about performance factor.