0

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.

j.a.estevan
  • 3,057
  • 18
  • 32
semantic_c0d3r
  • 819
  • 2
  • 15
  • 31
  • Can you try to replace the first line with `AxaptaObject dict = (AxaptaObject)DynAx.CallStaticClassMethod("Dictionary");` – user1416420 Feb 14 '13 at 06:37

1 Answers1

1

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.

semantic_c0d3r
  • 819
  • 2
  • 15
  • 31