Posts

Showing posts from 2016

How to read Excelfile using x++ code in ax 2012

Hi Guys, The following code will helps you to read Excel file using x++ code.   static void howToReadExcelSheet(Args _args)   {             SysExcelApplication                    application;             SysExcelWorkbooks                     workbooks;             SysExcelWorkbook                      workbook;             SysExcelWorksheets                    worksheets;             SysExcelWorksheet                      worksheet;             SysExcelCells                       ...

Dynamics AX7 Useful links

Hi Guys, Below are the few links help you to start learning AX7. http://viraldax.blogspot.in/2016/03/microsoft-dynamics-ax-7-how-to.html https://blogs.msdn.microsoft.com/axsupport/2016/03/23/get-started-developing-in-ax-7/ https://stoneridgesoftware.com/differences-in-development-for-microsoft-dynamics-ax-7/ https://community.dynamics.com/ax/b/axilitynet/archive/2015/12/10/ax7-sneak-peek-the-new-aot Thanks

How to get AOS Details in ax 2012

How to get AOS Details in ax 2012:- Hello All,The following is the information will help to get AOS details. Session is the class having useful methods to get AOS name and Port number,UserName. Session contains static methods which can be called without creating object. Session extends xSession class is having more information. The following is the code. Session   session; session = new Session(); info(strFmt("%1 %2  %3",session.AOSName(),session.aosPort(),session.UserId())); SysClientSessions , SysServerSessions , SysUsersonline are the classes and SysUsersOnline is the form to get more information regarding Users,Sessions,etc., Hope this will helps you.

x++ code to get Customer Address based on purpose in ax 2012

static void  customerAddress(Args _args) {     DirPartyPostalAddressView           dirPartyPostalAddrlocal;     DirPartyLocationRolesView           dirPartyLocationRoleslocal;     LogisticsLocationRole                   logisticsLocRole;     select firstOnly   * from dirPartyPostalAddrlocal order by RecId desc         exists join dirPartyLocationRoleslocal             where dirPartyLocationRoleslocal.Location   == dirPartyPostalAddrlocal.Location                 && dirPartyLocationRoleslocal.Party     ==     CustTable::find(_accountNum).Party//_dirpartyRecid                 //&& dirPartyPostalAddrlocal.IsPrimary == NoYes::No         exists j...

Financial Dimesnisons in ax 2012

x++ code to get financial dimensions of customer in ax 2012.     DimensionAttribute                              dimAttr;     DimensionAttributeValue                    dimAttrValue;     DimensionAttributeValueSetItem       dimAttrValueSet;   void customerFinacialDimensions(DimensionDefault  _defaultDimension) {       while  select DimensionAttributeValueSet,DimensionAttributeValue,DisplayValue from             dimAttrValueSet                 where dimAttrValueSet.DimensionAttributeValueSet    == _defaultDimension             join RecId,DimensionAttribute from dimAttrValue                 where dimAttrValue.RecId  == dimAttrVa...

x++ code to Insert Data into Table directly from Query in ax 2012

Hello Guys,the below is the process to insert data into table directly from query.     TestTable   testTable;     Query         query;     QueryBuildDataSource    qbds;     QueryBuildFieldList     qbdfieldList_customer;     QueryBuildRange         qbr;     Map                               fieldMappig;     delete_from testTable;     query = new Query();     qbds = query.addDataSource(tableNum(CustTable));     qbr = qbds.addRange(fieldNum(CustTable,Currency));     qbr.value('AUD');     qbdfieldList_customer = qbds.fields();     qbdfieldList_customer.addField(fieldNum(CustTable,Currency));     qbdfieldList_customer.addField(fieldNum(CustTable,AccountNum));     qbdfieldList_customer.a...

Commands to Export and Import Model in Dynamics ax 2012

Hello guys,the following commands will help you to import and export model in ax 2012. Export Model : ---------------------- On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell. At the Windows PowerShell command prompt, PS C:\>, type one of the following commands, and then press ENTER. Export-AXModel  -Model <name> -File <Filename.axmodel> Example:Export-AXModel  -Model TestModel -File D:\\models\testmodel.axmodel Here,TestModel is model name. Import Model ; -------------------------- Install-AXModel -File <Filename.axmodel> -Details or Install-AXModel -File <Filename.axmodel> -Details  -Conflict Push Example:C:> Install-AXModel -File    D:\\models\testmodel.axmodel  -Details Command to get list of models installed: ----------------------------------------------------- axutil  list Example:C:>axutil list  Comma...

Multiple calls to CodeAccessPermission.Assert error in ax 2012

Hello guys,maximum people will write their code like below statements to create 2 text files at a time. /* fileIOPermission = new FileIOPermission(filename,'w'); fileIOPermission.assert(); textIo = new TextIo(filename, 'w'); fileIOPermission1 = new FileIOPermission(filename1,'W'); fileIOPermission1.assert(); textIo1 = new TextIo(filename1, 'w'); */ The above statements will create a problem like"Multiple calls to CodeAccessPermission.Assert ". To solve,Please change your code as below. static void Job21(Args _args) {           Set   permissionSet;         TextIo    textIo,textIo1;         str filename,filename1;         filename = @'D;\testfile1.txt';         filename1=@'D:\testfile2.txt';         //creating Set Class Object of type class.         permissionSet = new Set(Types::Class);   ...
//Steps to restore model,Transactional database  files(.bak):-   1)First shrink the both model,Transactional Database to get free space //get SID use master; select * from  [ABC_AX_DEV].[dbo].[USERINFO] where id = 'Admin' //The following are the SQL commands: use master //for Transactional Database USE [ABC_AX_DEV] select file_id, name from sys.database_files dbcc shrinkfile(2,7) dbcc shrinkdatabase(1,7) //for model use [ABC_AX_DEV_model] select file_id, name from sys.database_files dbcc shrinkfile(2,7) dbcc shrinkdatabase(1,7) 2)select model restore-->device-->selct your ".bak" file--->do the below steps check OverWrite the existing database(WITH REPLACE). check close existing connections to destination database. 3)do the same steps for Transactional Database 4) if u get error after  restored  your DB,model "failed to logon MicrosoftDynamics AX"    Please get your old DB,model SID and update now. UPDAT...
x++ code to get Purchase order Voucher transactions either PO is cancelled or not Cancelled.      static void  Job(Args _args) {     GeneralJournalEntry                     genJourEntry;     GeneralJournalAccountEntry        genJourAccEntry;     container                                        conGeneralJourAccEntry;     //PO_receipt_1985 is the PackingSlipId       while select  DocumentNumber,RecId,JournalNumber,SubledgerVoucher from  genJourEntry         where genJourEntry.DocumentNumber == 'PO_receipt_1985'            join GeneralJournalEntry,PostingType,IsCorrection from genJourAccEntry         where  genJourAccEntry.GeneralJournalEntry  =...
       X++ code to create CSV file in ax 2012.     The TextIo,CommaIO  are the classes  used to create CSV files frequently.     In this post i'm using CommaIO class to create CSV file.      #static void CreateCSVFileJob(Args _args)     #{     #    CommaIO                  file;       #    FileIOPermission       fileIOPermission;     #    str                             filename;     #    #File     #    ;     #    /*     #    if(!fileNameLocation)     #    {     #        throw error('file location is empty');     #    }     #    *...
Frequent Best Practice Errors with solutions: 1)DeveloperDocumentation label should not be marked to be translated. --->write {locked} in description of a label. 2)The relation under the extended data type (EDT) ItemId must be migrated to a table relation. Consider using the EDT relation migration tool. --->GOTO-->>Tools-->>CodeUpgrade-->>EDT relationmigration tool.     Click MigrateAll. 3)The relation is marked to be validated, but its referenced fields are not fully covered by a primary or alternate index on the referenced table. --->Check 4)Field must be defined using a type. --->Always ship a table field with the same base type as it has been shipped with before. The size of the field must be the same, or greater than it has been before.     Each field must be defined using a type, or you will get an error. 5)The property Caption has a nondefault value @XYZ948. Expected @SYS9039. --->Not required. 6)Only for...
x++ code to get country region id based on legal entity static void test (Args _args) {     CompanyInfo                         companyInfo;     DirPartyTable                       dirPartyTable;     LogisticsLocation                   logisticsLocation;     LogisticsEntityPostalAddressView    logisticsEntityPostalAddressView;     ;     companyInfo = CompanyInfo::find();      dirPartyTable   = DirPartyTable::find(companyInfo.PartyNumber);    select firstonly IsPostalAddress,Recid,LocationId from   logisticsLocation             where  logisticsLocation.RecId  == dirPartyTable.PrimaryAddressLocation              && logistic...