Thursday, 27 February 2014

AX 2012 layer magic

Hi,
Many times it so happens that the developer is engrossed in his work and he happens to write his code in the wrong layer. This can cause big troubles when you are dealing with clients.
A very common scenario is:

You are working in the cus or isv layer. Suddenly during the development the client gets stuck and asks you to restart the client(very common in AX 2012). And then you click YES.

There is a bug in here. When the AX restarts, it will open the AX in the usr layer instead of the layer you were working in. So be careful here.

Wednesday, 26 February 2014

Error: Cannot create a record. Record already exists.

Hi,
Sometimes you would encounter this error no matter what you do.
If there is no technical flaw, just try these two steps:

1. Restart SQL Server service
2. Restart AOS

Monday, 17 February 2014

How do I deploy reports to for different AOS configurations using powershell?

Enter this command in the powershell:

Publish-AXReport –Id SSRSConfigID -ReportName SalesInvoice

SSRSConfigID refers to a configuration ID that was defined in Microsoft Dynamics AX. 

To view these configuration IDs, open Microsoft Dynamics AX and then open the Report servers form. (Click System administration > Setup > Business intelligence > Reporting Services > Report servers.) To deploy reports to the new Reporting Services instance, enter the configuration ID that is associated with that instance.

How do I set a default tab in a form?

Many times, you want a particular tab to be selected by default against a certain condition. This can be accomplished by simply calling the tabName.activePage() method. 

Saturday, 15 February 2014

Update conflict while posting credit note against fully invoiced Sales order



Hi,
At times you would receive this strange error all of a sudden that would not let you post a credit note. In particular, when you do not want the sales order lines to be deleted and wish to retain the original order.
In order to fix this bug, just add a line a code in the "SalesCopying" class.


In the copy method, just add this line highlighted in green. In my environment, this is line no 530.



Thursday, 14 November 2013

How do I add scan-able barcode in my SSRS report?

Many times we need to show a barcode on ssrs report.
We might need it for SalesId, PurchId, ItemId, CustId etc.

Follow these steps to implement this:

1. On the temporary table of the ssrs report, add a new string field "Mybarcode".
2. Set the extended data type property to "BarCodeString".

Now we have added the field that would hold the barcode string. Now there are two phases we need to cover:
1. Implement logic in our report data provider class (RDP class) to populate our field "Mybarcode" with the barcode string.
2. Make changes in our report designer to display the newly added barcode field.

Add this code in your RDP class, in this example we are using ItemId field.
    Mybarcode= BarcodeCode128::construct();
    Mybarcode.string(true,myTmpTable.ItemId);
    Mybarcode.encode();
    myTmpTable.Mybarcode= barcodePurch.barcodeStr(); 
2.  Now open your ssrs report in the visual studio, update the data set. Make sure, it shows the newly added field.

Add a new text box in the report designer, set the expression and font as shown in the attached screenshots.
Well that's all you need to do.




Monday, 10 June 2013

How do I fetch data if my table/view name comes as a parameter in a string?

Well, that's where I got stuck once.
But after much investigation, I discovered the solution.

You can make use of SysDictTable class here, pass the name as a string and store the data in buffer of type Common so that no error is raised.


SysDictTable dictTable = SysDictTable::newName('myTableName');
Common common = dictTable.makeRecord();

Now if you want to read a particular field "Description" from table myTableName, if you try doing that by writing Common.Description  you would get an error.

Instead, you should follow this method:

while select common
{
info (common.(dictTable.fieldName2Id('Description')));
}