Posts

Showing posts with the label AX2012

Force synchronization in Microsoft Dynamics AX 2012 using X++

    Dictionary              dictionary;     int                     iLoop;       int                     totalTablesCount;     TableId                 tableId;     Application             application;     SysOperationProgress    progress;     StackBase               errorStackBase;     ErrorTxt                error;     ;     application         = new Application();     dictionary          = new Dictionary();     totalTablesCount    = dictionary.tableCnt();          ...

How can download attachment file in Microsoft Dynamics AX using DocumentHandlingService and C#(API)?

         public FileResult fileDownload(long  docRefRecId,string fileName)         {                        byte[]                                                    fileByte;             CallContext                                      context = new CallContext();             DocumentHandlingServiceClient  client    = new DocumentHandlingServiceClient();             DocumentFileDataContract           contract;               client.ClientCredentials.Windows.ClientCredential.D...

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++)     {   ...

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)      {       ...

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...

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                ...

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; }

How to loop through enum in dynamics ax 2012 using x++

    Method 1:     SysDictEnum                 sysDictEnum = new SysDictEnum(enumnum(InventTransType));     InventTransType             currentElement;              currentElement= sysDictEnum.firstValue();     do     {         info(strFmt("%1",currentElement));                  currentElement= sysDictEnum.nextValue(currentElement);              } while (currentElement != sysDictEnum.firstValue()); Method 2:     SysDictEnum                 sysDictEnum = new SysDictEnum(enumnum(InventTransType));     InventTransType             currentElement;     int                  ...

How to override lookupReference for reference group in Dynamics Ax 2012 using X++

  public Common lookupReference(FormReferenceControl _formReferenceControl) { Query query = new Query(); QueryBuildDataSource qbds; QueryBuildRange range; SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(HcmWorker), _formReferenceControl, true); sysTableLookup.addLookupField(fieldNum(HcmWorker, PersonnelNumber)); sysTableLookup.addLookupField(fieldNum(HcmWorker, Person)); sysTableLookup.parmQuery(query); qbds = query.addDataSource(tableNum(HcmWorker)); range = SysQuery::findOrCreateRange(qbds,fieldNum(HcmWorker,PersonnelNumber)); range.value(SysQuery::valueLikeAfter('10')); return sysTableLookup.performFormLookup(); }

How to convert between units in Dynamics AX 2012 using X++?

  Qty unitConv(ItemId            _itemId,                         UnitIDBase    _fromUnit,                         UnitIDbase     _toUnit,                         Qty                 _qty) {          Qty                                                    ret;        UnitOfMeasureConverter_Product  unitConverter   = UnitOfMeasureConverter_Product::construct();                   unitConverter.parmProduct(InventTable::find(_itemId).Product);     unitConverter....

Use the PreProcess report to handle the huge data and time out issue for SSRS reports in Dynamics AX 2012 R3

Extends the DP class from SrsReportDataProviderPreProcessTempDB : [     SRSReportParameterAttribute(classStr(ClassNameContract)) ] class ClassNameDP extends SrsReportDataProviderPreProcessTempDB {      TableNameTmp               tableNameTmpList; } Write the processReport method:   public void processReport() { ClassNameContract        contract                             = this.parmDataContract() as ClassNameContract; RecordInsertList           dataRecordInsertList = new                                                                          RecordInsertList(tabl...

How to add custom lookup (Multi tables)in Dynamics AX 2012 Through X++

  How to add custom lookup (Multi tables)in Dynamics AX 2012 Through X++ public static void lookupInvoice(FormControl _formControl, str _filterStr) {     Query                                           query                               = new Query();     QueryBuildDataSource            qbds;     QueryBuildDataSource            qbds_HcmWorker;     QueryBuildDataSource            qbds_DirPerson;     SysMultiTableLookup             SysMultiTableLookup;     qbds                                   = query.addDataSource(...
How to  Update default dimension with "Fixed value" on a main account  in ax 2012 static void tbs_UpdateMainAccountDefaultDimensions(Args _args) {     MainAccountRecId                mainAccountRecid        = 5637172326;     DataAreaId                      dataAreaId              = "CompanyId";     CompanyInfo                     companyInfo             = CompanyInfo::findDataArea( CompanyId );     MainAccountLegalEntity          mainAccountLegalEntity  = MainAccountLegalEntity::findByMainAccountLegalEntity(mainAccountRecId,companyInfo.RecId,true);     DimensionValue                  costCenter ...
How to add custom lookup (Multi Companies)in Dynamics AX 2012 Through X++ public void lookup(FormControl _formControl, str _filterStr) {         //super(_formControl, _filterStr);         Query                               query                               = new Query();         QueryBuildDataSource    queryBuildDataSource;         SysTableLookup               sysTableLookup;         query.allowCrossCompany(true);         sysTableLookup          = SysTableLookup::newParameters(tableNum(TaxGroupHeading), _ formControl);         queryBuildDataSource    = query.addDataSource(tableNum(TaxGroupHea...
How to import free text invoice in ax 2012 static void importFreeTextInvoice(Args _args) {     SysExcelApplication     application;     SysExcelWorkbooks       workbooks;     SysExcelWorkbook        workbook;     SysExcelWorksheets      worksheets;     SysExcelWorksheet       worksheet;     SysExcelCells           cells;     COMVariantType          type;     Dialog                  dialog;     Filename                filename;     DialogField             dialogFilename;     container               conFilter = ["Microsoft Excel Worksheets (.xlsx)" ,"*.xlsx"]; ...

How to add financial dimensions on form in ax 2012

How to add financial dimensions on form in ax 2012 ·         Add  TabPage  called  FinancialDimensionsTabPage   which should have the property  AutoDeclaration  set to  Yes ·         In classdeclaration declared the DimensionDefaultingController : class FormRun extends ObjectRun {     DimensionDefaultingController     dimensionDefaultingController; } ·         In the form’s override  Init method: public void init() {           super();            dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(true, true, true, 0, this, FinancialDimensionsTabPage, "@SYS138487");  dimensionDefaultingController.parmAttributeValueSetDataSource(Table...
Run the DP class (SSRS) in Dynamics AX 2012     DemoContract        contract    = new DemoContract();     DemoDP                 dp             = new DemoDP();     QueryBuildDataSource                qbds;     Query                                            query;     TableNameTmp                tableNameTmp;     contract.parmFromDate(mkDate(1,4,2019));     contract.parmToDate(mkDate(31,12,2019));          query       = dp.parmQuery();     qbds        = query.dataSourceTable(tableNum(CustTable));     ...

How to add custom lookup in Dynamics AX 2012 Through X++

How to add custom lookup in Dynamics AX 2012 Through X++ public void lookup(FormControl _formControl, str _filterStr) {         //super(_formControl, _filterStr);         Query                               query = new Query();         QueryBuildDataSource    queryBuildDataSource;         SysTableLookup               sysTableLookup;              sysTableLookup          = SysTableLookup::newParameters(tableNum(TableName), _formControl);         queryBuildDataSource    = query.addDataSource(tableNum(TableName));                  sysTableLookup.addLookupField(fieldNum( TableName , Field1));         s...