Posts

Showing posts from December, 2020

How to lookup list of methods (return type) in specific table in Microsoft Dynamics Ax 2012

    DictTable                          dictTable;     DictMethod                   dictMethod;     DisplayFunctionType     displayFunctionType;     DictType                dictType;     int                     methodCount;     int                     iCount;          dictTable           = new DictTable(tableNum(AssetTable));     methodCount         = dictTable.objectMethodCnt();     setPrefix(strFmt("Table name: %1", dictTable.name()));          for (iCount = 1; iCount <= methodCount; iCount++)     {         dictMethod          = dictTable.objectMethodObject(iCount);         displayFunctionType = dictMethod.displayType();         if (displayFunctionType == DisplayFunctionType::Get)         {             dictType = new DictType(dictMethod.returnId());             info(strFmt("Method name: %1 , Type : %2 ,Label: %3", dictMethod.name(),dictType.baseType(), dictType.label()));         }     }

How to create csv file in Dynamics AX 2012 Through X++

     #File      CommaTextIo            commaTextIo_File;      container                    file_Line;      CustTable                   custTable;      FileIoPermission       permission;      Filename                    fileName            = @"C:\\Temp\\FileName.csv";           permission                = new FileIoPermission(fileName, #io_write);      permission.assert();      commaTextIo_File   = new CommaTextIo(fileName, #io_write);      if (!commaTextIo_File || commaTextIo_File.status() != IO_Status::Ok)      {         throw error("Error when try create file.");      }      commaTextIo_File.outRecordDelimiter('\r\n');      commaTextIo_File.outFieldDelimiter(',');      while select firstonly10 CustTable      {          file_Line = [CustTable.AccountNum,CustTable.name()];          commaTextIo_File.writeExp(file_Line);      }      CodeAccessPermission::revertAssert();      info(strFmt("File created in the following path: %1.", filename));

How to create lookup of all tables in Dynamics AX 2012 using X++

 static void tableLookup(FormControl _formControl, str _filterStr) {     Query                                           query                   = new Query();     QueryBuildDataSource                queryBuildDataSource;     SysTableLookup                          sysTableLookup;     QueryBuildRange                        range;     AXTableTmp                               tables;     SysModelElement                        sysModelElement;     DictTable                                     dictTable;     while select sysModelElement            where sysModelElement.ElementType    == UtilElementType::Table //              && sysModelElement.ParentId          == _tableId               && sysModelElement.AxId                 != 0     {         dictTable = new DictTable(sysModelElement.AxId);         if (!dictTable.isSystemTable())         {             tables.clear();             tables.Id                    = sysModelElement.AxId;             tables.TableName     = sysMod

How to create lookup of all fields in a table in Dynamics AX 2012 using X++

 static void fieldLookup(FormControl _formControl, str _filterStr,TableId    _tableId) {     Query                                               query                   = new Query();     QueryBuildDataSource                queryBuildDataSource;     SysTableLookup                             sysTableLookup;     QueryBuildRange                         range;     AXFieldTmp                                fields;     SysModelElement                        sysModelElement;     DictField                                      dictField;     while select sysModelElement            where sysModelElement.ElementType    == UtilElementType::TableField               && sysModelElement.ParentId            == _tableId               && sysModelElement.AxId                 != 0     {         dictField = new DictField(_tableId,sysModelElement.AxId);         if (!(dictField.name() like "DEL_*"))         {             switch(dictField.baseType())             {                 cas

How to get table label in dynamics ax 2012 using x++

 display TableLabel getTableLabel() {     FieldLabel      ret;     DictTable       dictTable;     TableId           tableId     = tableNum(Salestable);     if(tableId)     {         dictTable   = new DictTable(tableId);         ret             = dictTable.label();     }     return ret; }

How to get field type in dynamics ax 2012 using x++

 display FieldType fieldType() {     FieldType       ret;     DictField       dictField;     TableId         tableId     = tableNum(PurchLine);     FieldId         fieldId     = fieldName2id(tableId,"Field Name");     if(tableId && fieldId)     {         dictField   = new DictField(tableId,fieldId);         ret            = dictField.baseType();     }     return ret; }

How to get field label in dynamics ax 2012 using x++

 display FieldLabel fieldLabel() {     FieldLabel      ret;     DictField       dictField;     TableId          tableId     = tableNum(PurchLine);     FieldId          fieldId     = fieldName2id(tableId,"Field Name");          if(tableId && fieldId)     {         dictField   = new DictField(tableId,fieldId);         ret             = dictField.label();     }     return ret; }