Monday, February 13, 2017

Get Model element type name from its ID

Just to cover a gap in system data, you can use the following code to get a model element type name based on its ID in AX 2012. Thanks to Martin Drab!

static void tmxElementTypes(Args _args)
{
    int             elementTypeId = 300;
    str             elementTypeName;
    
    switch (elementTypeId)
    {
        case 1 : elementTypeName = 'DisplayTool'; break;
        case 2 : elementTypeName = 'OutputTool'; break;
        case 3 : elementTypeName = 'ActionTool'; break;
        case 4 : elementTypeName = 'Macro'; break;
        case 5 : elementTypeName = 'Job'; break;
        case 6 : elementTypeName = 'WorkflowProcess'; break;
        case 7 : elementTypeName = 'AdminUserSetup'; break;
        case 8 : elementTypeName = 'SysXal'; break;
        case 9 : elementTypeName = 'UserSetupQuery'; break;
        case 10 : elementTypeName = 'LegacyMenu'; break;
        case 11 : elementTypeName = 'Form'; break;
        case 12 : elementTypeName = 'TableInstanceMethod'; break;
        case 13 : elementTypeName = 'ClassStaticMethod'; break;
        case 14 : elementTypeName = 'ClassInstanceMethod'; break;
        case 15 : elementTypeName = 'LicenseCode'; break;
        case 16 : elementTypeName = 'Menu'; break;
        case 17 : elementTypeName = 'UserMenu'; break;
        case 18 : elementTypeName = 'Report'; break;
        case 19 : elementTypeName = 'ReportTemplate'; break;
        case 20 : elementTypeName = 'Query'; break;
        case 21 : elementTypeName = 'Resource'; break;
        case 22 : elementTypeName = 'TableStaticMethod'; break;
        case 23 : elementTypeName = 'ClassInternalHeader'; break;
        case 24 : elementTypeName = 'TableInternalHeader'; break;
        case 25 : elementTypeName = 'TableRelation'; break;
        case 26 : elementTypeName = 'TableMap'; break;
        case 27 : elementTypeName = 'ReportSectionTemplate'; break;
        case 28 : elementTypeName = 'ViewQuery'; break;
        case 29 : elementTypeName = 'Usersetup'; break;
        case 30 : elementTypeName = 'WebMenu'; break;
        case 33 : elementTypeName = 'RESERVED33'; break;
        case 34 : elementTypeName = 'WebForm'; break;
        case 35 : elementTypeName = 'ConfigurationKey'; break;
        case 36 : elementTypeName = 'SecurityKey'; break;
        case 37 : elementTypeName = 'SharedProject'; break;
        case 38 : elementTypeName = 'PrivateProject'; break;
        case 39 : elementTypeName = 'LegacyFeatureKey'; break;
        case 40 : elementTypeName = 'Enum'; break;
        case 41 : elementTypeName = 'ExtendedType'; break;
        case 42 : elementTypeName = 'TableField'; break;
        case 43 : elementTypeName = 'TableIndex'; break;
        case 44 : elementTypeName = 'Table'; break;
        case 45 : elementTypeName = 'Class'; break;
        case 46 : elementTypeName = 'TableFieldGroup'; break;
        case 47 : elementTypeName = 'ReportUser'; break;
        case 48 : elementTypeName = 'TableCollection'; break;
        case 52 : elementTypeName = 'WebReport'; break;
        case 53 : elementTypeName = 'Reference'; break;
        case 55 : elementTypeName = 'WebUrlItem'; break;
        case 56 : elementTypeName = 'WebActionItem'; break;
        case 57 : elementTypeName = 'WebDisplayContentItem'; break;
        case 58 : elementTypeName = 'WebOutputContentItem'; break;
        case 59 : elementTypeName = 'WebletItem'; break;
        case 60 : elementTypeName = 'WebWebPart'; break;
        case 61 : elementTypeName = 'WebSiteDef'; break;
        case 62 : elementTypeName = 'WebSiteTemp'; break;
        case 63 : elementTypeName = 'WebPageDef'; break;
        case 64 : elementTypeName = 'WebStaticFile'; break;
        case 66 : elementTypeName = 'Perspective'; break;
        case 67 : elementTypeName = 'WebModule'; break;
        case 68 : elementTypeName = 'WorkflowType'; break;
        case 69 : elementTypeName = 'WorkflowTask'; break;
        case 70 : elementTypeName = 'WorkflowApproval'; break;
        case 71 : elementTypeName = 'WorkflowCategory'; break;
        case 72 : elementTypeName = 'DataSet'; break;
        case 73 : elementTypeName = 'WebControl'; break;
        case 74 : elementTypeName = 'WebSourceFile'; break;
        case 75 : elementTypeName = 'WebManagedContentItem'; break;
        case 76 : elementTypeName = 'Service'; break;
        case 77 : elementTypeName = 'CompositeQueryNode'; break;
        case 78 : elementTypeName = 'WebListDef'; break;
        case 79 : elementTypeName = 'ReportLibrary'; break;
        case 80 : elementTypeName = 'SecurityTask'; break;
        case 81 : elementTypeName = 'InfoPart'; break;
        case 82 : elementTypeName = 'FormPart'; break;
        case 83 : elementTypeName = 'PartReference'; break;
        case 85 : elementTypeName = 'SSRSReport'; break;
        case 87 : elementTypeName = 'SSRSReportLayoutTemplate'; break;
        case 88 : elementTypeName = 'SSRSReportListStyleTemplate'; break;
        case 89 : elementTypeName = 'SSRSReportMatrixStyleTemplate'; break;
        case 90 : elementTypeName = 'SSRSReportPieChartStyleTemplate'; break;
        case 91 : elementTypeName = 'SSRSReportTableStyleTemplate'; break;
        case 92 : elementTypeName = 'SSRSReportXYChartStyleTemplate'; break;
        case 93 : elementTypeName = 'SSRSReportDataSource'; break;
        case 94 : elementTypeName = 'SSRSReportImage'; break;
        case 95 : elementTypeName = 'WorkflowAutomatedTask'; break;
        case 96 : elementTypeName = 'Event'; break;
        case 97 : elementTypeName = 'EventHandler'; break;
        case 98 : elementTypeName = 'Cue'; break;
        case 99 : elementTypeName = 'CueGroup'; break;
        case 100 : elementTypeName = 'CueReference'; break;
        case 101 : elementTypeName = 'DocSet'; break;
        case 104 : elementTypeName = 'VisualStudioProjectFolder'; break;
        case 105 : elementTypeName = 'VisualStudioProjectFile'; break;
        case 106 : elementTypeName = 'InfoPartLayout'; break;
        case 107 : elementTypeName = 'InfoPartGroup'; break;
        case 108 : elementTypeName = 'InfoPartField'; break;
        case 109 : elementTypeName = 'InfoPartAction'; break;
        case 110 : elementTypeName = 'MenuItem'; break;
        case 111 : elementTypeName = 'MenuSeparator'; break;
        case 112 : elementTypeName = 'MenuReference'; break;
        case 113 : elementTypeName = 'TableFullTextIndex'; break;
        case 114 : elementTypeName = 'VisualStudioProjectType'; break;
        case 115 : elementTypeName = 'SecCodePermission'; break;
        case 116 : elementTypeName = 'EventHandlerMethod'; break;
        case 117 : elementTypeName = 'LabelFile'; break;
        case 118 : elementTypeName = 'LabelFileLanguage'; break;
        case 119 : elementTypeName = 'SecPolicy'; break;
        case 120 : elementTypeName = 'FormMethod'; break;
        case 121 : elementTypeName = 'VisualStudioProjectLink'; break;
        case 122 : elementTypeName = 'SubMenu'; break;
        case 123 : elementTypeName = 'SubWebMenu'; break;
        case 124 : elementTypeName = 'SubWebModule'; break;
        case 125 : elementTypeName = 'FormDesign'; break;
        case 126 : elementTypeName = 'FormControl'; break;
        case 127 : elementTypeName = 'VSProject_AXModel'; break;
        case 128 : elementTypeName = 'VSProject_CSharp'; break;
        case 129 : elementTypeName = 'VSProject_VB'; break;
        case 130 : elementTypeName = 'VSProject_Web'; break;
        case 131 : elementTypeName = 'VSProject_Analysis'; break;
        case 133 : elementTypeName = 'SecRole'; break;
        case 134 : elementTypeName = 'SecPrivilege'; break;
        case 135 : elementTypeName = 'SecDuty'; break;
        case 136 : elementTypeName = 'SecProcessCycle'; break;
        case 137 : elementTypeName = 'ServiceGroup'; break;
        case 138 : elementTypeName = 'ServiceNodeReference'; break;
        case 139 : elementTypeName = 'WorkflowHierarchyProvider'; break;
        case 140 : elementTypeName = 'WorkflowParticipantProvider'; break;
        case 141 : elementTypeName = 'WorkflowQueueProvider'; break;
        case 142 : elementTypeName = 'WorkflowDueDateProvider'; break;
        case 143 : elementTypeName = 'FormDataSources'; break;
        case 144 : elementTypeName = 'SecurityPermissionSet'; break;
        default :
            elementTypeName = 'Error: not implemented';
            warning(strFmt("Element type %1 : %2", elementTypeId, elementTypeName));
    }
    info(strFmt("Element type %1 : %2", elementTypeId, elementTypeName));
}

No comments: