static void Job_ExportAOTObject(Args _args)
{
TreeNode treeNode;
FileIoPermission perm;
str treeNodeName;
str path;
// #AOT is defined in the AOT under Macros.
#AOT
;
//Replace with '\Classes' for class and '\Forms' for form
treeNode = TreeNode::findNode(@'\Data Dictionary\Tables';);
treeNode = [Link]();
while(treeNode)
{
treeNodeName = [Link]();
path = @'C:\AOT\' + treeNodeName + '.xpo';
perm = new FileIoPermission(path, 'w');
if (perm == null)
{
throw error('Unable to create file for ' + treeNodeName);
}
[Link]();
[Link](path);
CodeAccessPermission::revertAssert();
treeNode = [Link]();
}
}
// Uses the full path to obtain the node for the new enum element
// that this job creates near its completion.
tnode2Enum = TreeNode::findNode(#BaseEnumsPath);
static void Job_ExportAOTObject(Args _args)
{
TreeNode treeNode;
FileIoPermission perm;
str treeNodeName;
str path;
EnumId enumId;
DictEnum dictEnum;
int count;
int counter;
// #AOT is defined in the AOT under Macros.
#AOT
;
//Replace with '\Classes' for class and '\Forms' for form
treeNode = TreeNode::findNode(#BaseEnumsPath);
treeNode = [Link]();
while(treeNode)
{
treeNodeName = [Link]();
enumId = enumNum(treeNodeName);
dictEnum = new DictEnum(enumId);
count = [Link]();
for(counter = 0; counter < count; counter ++)
{
// You can use the number of method exposed by DictEnum class
// [Link](counter)
// dictEnum.index2Value(counter)
// dictEnum.index2Symbol(counter)
// dictEnum.index2Label(counter)
}
treeNode = [Link]();
count =0;
}
}
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
//Traverse tables and for each table traverse fields using AOT
[Link]
List all the objects on menus
(forms/Reports) AX 2009/ 2012
[Link]
1. //Tina van der Vyver
2. //[Link]
3. static void ListFields(Args _args)
4. {
5. #File
6. DictField dictField;
7. DictTable dictTable;
8. DictType dictType;
9. DictEnum dictEnum;
10. FieldId fieldId;
11. Types type;
12. TableName tableName = tableStr(BatchJob);
13.
14. str enumValues, stringLength, stringType;
15. int i;
16.
17. CommaTextIo commaTextIo;
18. FileIOPermission permission;
19. str fileName = strFmt(@"C:\%[Link]", tableName);
20. ;
21. permission = new FileIOPermission(fileName, #io_write);
22. [Link]();
23.
24. commaTextIo = new CommaTextIo(fileName ,#io_write);
25. dictTable = new dictTable(tableName2Id(tableName));
26. fieldId = [Link](0);
27.
28. if (fieldId)
29. {
30. [Link]("Displayed name", "Technical Name", "Data Type");
31. }
32.
33. while (fieldId)
34. {
35. dictField = new DictField(tableName2Id(tableName), fieldId);
36.
37. if (dictField && ![Link]())
38. {
39. type = [Link]();
40.
41. switch (type)
42. {
43. case Types::String:
44. dictType = new DictType([Link]());
45. stringLength = (strFmt("%1[%2]",type,
[Link]()));
46.
47. [Link]([Link](), [Link](),
stringLength);
48. break;
49.
50. case Types::Enum:
51. dictEnum = new DictEnum([Link]());
52.
53. for (i = 0; i < [Link](); i++)
54. {
55. if (i == 0)
56. {
57. enumValues = "Enumeration: ";
58. }
59. else
60. {
61. enumValues += "/";
62. }
63.
64. if (dictEnum.value2Name(i))
65. {
66. enumValues += dictEnum.value2Name(i);
67. }
68. else
69. {
70. enumValues += dictEnum.value2Name(i);
71. }
72. }
73.
74. [Link]([Link](), [Link](), enumValues);
75. enumValues = '';
76. break;
77.
78. default:
79. stringType = strFmt("%1", type);
80. [Link]([Link](), [Link](),
stringType);
81. break;
82. }
83. }
84. fieldId = [Link](fieldId);
85. }
86. CodeAccessPermission::revertAssert();
87. }