Posts

Showing posts from 2015

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"

When you log on to a Microsoft Dynamics AX 4.0 client after you restore a database, you receive the following error message: You are not a recognized user of Microsoft Dynamics AX. Contact your system administrator for help. This problem occurs if you restore a Microsoft Dynamics AX 4.0 environment in a different Active Directory directory service environment. This problem occurs when one or more of the following conditions are true: The security identifier (SID) is incorrect. The network alias is incorrect. The network domain is incorrect Resolution To resolve this problem, run the following script in SQL Query Analyzer after you restore the database. Note  You must obtain a SID in the current Microsoft Dynamics AX 4.0 environment. --Extract the user's SID from the current installation to update the restored database. select id, SID, Networkdomain, networkalias from userinfo where Id = 'admin'-- networkalias = '<UserAlias>' To extract t

Resolution Of Error Code 50109 in AX

Stop the AOS, delete the axapd.aoi file and restart the AOS. Path : C:\Program Files (x86)\Microsoft Dynamics AX\40\Application\Appl\Standard This is the object index file. AX generates a new one if it is not present when the AOS starts. Restart may seem slow. That's because of the time it takes to regenerate the index file.

SSRS Report Expression to Format Number

FormatNumber(<NumberField>, <Count>) i.e. <NumberField>  Refers to the number to be formatted, <Count>              Refers to the No of Decimal Places.

SSRS Development

Image
Without going into more details over individual classes (RDP, Contract, UI Builder and Controller) I am writing this post to develop an SSRS report using all these classes (some of them are optional). Let’s find out how? RDP Class Details of this class are here; http://www.dynamics101.com/2013/09/developing-ssrs-report-using-report-data-provider-microsoft-dynamics-ax-2012/ Create a new class in AOT, I have named it FF_ReportDP and  extends  it from SRSReportDataProviderBase SRSReportQueryAttribute : specifies which AOT query will be used in this report. If the RDP class uses an AOT query to process data, define this attribute at the beginning of the class. SRSReportParameterAttribute : defines the data contract class that will be used by this report to prompt for parameter values. If the RDP class contains any parameters this define this attribute at the beginning of the class. NOTE:  Both the attributes are optional. If the report does not use any query or

Barcode in AX 2012

Barcode         Mybarcode; Mybarcode = BarcodeCode39::construct(); Mybarcode.string(true,_yourtable.Id ); Mybarcode.encode(); _yourTmpTable.Barcode= Mybarcode.barcodeStr(); _yourTmpTable.BarcodeHR= Mybarcode.barcodeStrHR();

Retrieve Lines from a string containing multiple lines using StrLine() Function

str strLine(str string, int count) Example: static void strLineExample(Args _arg) { str mytxt = "first-line\nsecond-line\nlast-line"; ; // Prints "second-line". print strLine(mytxt,1); // Prints "last-line". print strLine(mytxt,2); pause; } https://msdn.microsoft.com/en-us/library/aa577258.aspx

Adding relations among Table Using X++

Adding relations among tables if they don't exist at table level and  adding range QueryBuildDataSource    qbds;         qbds = this.query().dataSourceTable(tableNum(SalesTable)); qbds.addLink(fieldNum(SalesLine, SalesId), fieldNum(SalesTable, SalesId)); //Adding range qbds.addRange(fieldNum(RouteVersion,SalesId )).value('01');

Passing Records among Forms on Specific Action using Args

Assume a scenario where we have two forms (1)Sales Table (2)Customer Table and we have to pass records from one form to other form on a specific action (e.g. clicked ...)  first declare Args object as follow: Args args; args = new args(); Then specify the record to be passed (assume that Sales Table is the data Source of our form): args.record(salesTable.SalesId); now our record is set in args.record, to pass it to another form call that form as follow:     new MenuFunction(menuitemDisplayStr(CustTable), MenuItemType::Display).run(args); This line of code will rum the customers form and now we can use that record . In addition to check whether our record is valid i.e.it's not Null or its data-source is Sales Table or not.... if(element.args().record() && element.args().dataset() == tableNum(SalesTable)) {      custTableLocal = element.args().record(); } The above line of code verify the record and its data set i.e. Sales Table and allocate that record to

Exporting Data from AX to text file

static void DemoExporttoExcel(Args _args) {    TextIO file;     container line;    InventTable                    inventTable;    #File    #define.filename('C:\\Data.csv')    ;    //Filename    file = new TextIO(#fileName, #io_write);    file.outFieldDelimiter(';');// for semicolon seperator     if (!file || file.status() != IO_Status::Ok)     {     throw error("File cannot be opened.");     }    while select inventTable    {       line = [inventTable.itemId];         file.writeExp(line);    }   }

To limit Text Box Characters in SSRS report

Often there is a requirement to limit the Text Box size to Specified number of characters , although there is a  canGrow   property on the text box which if set to no  restricts the characters to be displayed but if the number of characters is specified than its not the right way. to achieve the requirement use : Left(fields!data.value,40) It will limit the number of characters to the number specifies i.e 40 in this case. 

Exporting data from AX to Excel

static void DemoExporttoExcel(Args _args) {  SysExcelApplication  xlsApplication;    SysExcelWorkBooks    xlsWorkBookCollection;    SysExcelWorkBook     xlsWorkBook;    SysExcelWorkSheets   xlsWorkSheetCollection;    SysExcelWorkSheet    xlsWorkSheet;    SysExcelRange            xlsRange;    InventDimCombination inventDimCombination;     InventDim                      inventDim;    int                  row = 1;    str                  fileName;    ;    //Filename    fileName = "C:\\demo";    //Initialize Excel instance    xlsApplication           = SysExcelApplication::construct();    //Open Excel document    //xlsApplication.visible(true);    //Create Excel WorkBook and WorkSheet    xlsWorkBookCollection    = xlsApplication.workbooks();    xlsWorkBook              = xlsWorkBookCollection.add();    xlsWorkSheetCollection   = xlsWorkBook.worksheets();    xlsWorkSheet             = xlsWorkSheetCollection.itemFromNum(1);    //Excel columns captions    xl

Creating Batch jobs using RunBaseBatch when importing data from a CSV file.

First create a new class and  extend it from RunBaseBatch. i.e.  class DemoBatchJob extends RunbaseBatch{} In the class declaration add the following. class DemoBatchJob extends RunbaseBatch  {    DialogRunbase    dlg;   DialogField       _file;   FilenameOpen   file;  # define.CurrentVersion(1)  # localmacro.CurrentList file //file variable is to keep in track the CSV file path for the batch job  # endmacro } Override the pack method.     public container pack()  { return [#CurrentVersion, #CurrentList]; }  Override the unpack method.   public boolean unpack(container _packedClass)  { Integer version = RunBase::getVersion(_packedClass);  ; switch (version) { case #CurrentVersion: [version, #CurrentList] = _packedClass; break; default: return false; } return true; } Override the dialog method.  protected Object dialog()  { dlg = super();    

Full CIL generation error : " The CIL generator found errors and could not save the new assembly"

Image
Follow the below mentioned 5 steps: Step 1:  Stop the AOS services Step 2:  Delete all of the source in the   C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL directory Step 3:  Start the AOS services Step 4:   Perform a full compile i.e full AOT Compile(it would take some time)   Perform full compilation in parallel to save time refer to the following post: Full AOT compilation in parallel using command line Once the full compilation is completed check the log file for any error during the compilation an first fix those errors.. The log can be viewed on the path:  C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\Log Step 5:  Perform a full CIL generation Now the issue would be resolved:-)

Full AOT compilation in parallel using command line

cd \Program Files\Microsoft Dynamics AX\60\Server\<YOUR AOS NAME>\bin axbuild.exe xppcompileall /aos=01 /altbin="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /workers=4 C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin>axbuild .exe xppcompileall /s=01

Full AOT compilation in parallel using command line

cd \Program Files\Microsoft Dynamics AX\60\Server\<YOUR AOS NAME>\bin axbuild.exe xppcompileall /aos=01 /altbin="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /workers=4 C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin>axbuild.exe xppcompileall /s=01

Debugging Report Data Provider Class

https://technet.microsoft.com/en-us/library/gg724081.aspx

Financial Dimensions Setup on a tab page

Image
On particular table add DefaultDimension field and make the relation such that: On the Particular forms CalssDeclearation write following code:  ----------------------------------------------------------------------------- DimensionDefaultingController   dimensionDefaultingController; ------------------------------------------------------------------------------ Override the forms Init method and add following lines of code: ----------------------------------------------------------------------------------------------------------------------     dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(     true, true, true/*financialsDimensionsEnabled*/, 0, this,<Tab Page Name> , "@SYS138491");     dimensionDefaultingController.parmAttributeValueSetDataSource(<dataset name_ds>,         fieldStr(<table name>, <field name>)); ------------------------------------------------------------------------------------

To Deploy SSRS reports using Microsoft Dynamics Ax 2012 Management Shell

To deploy a specific report, enter the name of the report. For example, to deploy the CustTransList report, enter the following command: Microsoft Dynamics AX Management Shell: *************************************** Publish - AXReport  - ReportName CustTransList *************************************** To deploy two or more specific reports, enter the names of the reports. For example, to deploy the CustTransList and CustTransOpenPerDate reports, enter the following command: Microsoft Dynamics AX Management Shell: ********************************************************** Publish - AXReport - ReportName CustTransList, CustTransOpenPerDate ***************************************************************** To deploy all reports, enter the following command: Microsoft Dynamics AX Management Shell: **************************** Publish - AXReport –ReportName * *******************************

Creating a Querie having multiple Data sources

Image
In this post we will be creating a Query having multiple Data sources which be be further used in some other places such as forms, parts, Reports etc. In this scenario we will be having 3 different tables i.e. Students, StudentsCourses and Courses table. We will be creating a query containing these 3 tables as data source in a specific way such that their relation is maintained. Below are the following three tables: Now let's create our desired query: Go to Queries Node in the AOT. Right Click on Query and Select New Query. Rename the Query to "DemoQuery".  We are all done with creating our Query.  Now we will be adding Data Sources to our Query. Open a new AOT (CTRL+D) and navigate to the Data Dictionary --> Tables and select the required table. in this case we will select Students Table and drag it on the Data Source Node of our Query. Expand the Students node and Set the Fields Dynamic Property to Yes. This will add all the Ta