Category: Uncategorized


Recently, I got a requirement to replace financial dimension value using X++ code based on certain conditions for an Inventory journal record. I was trying to do this using AxdDimensionUtil class by calling method getDimensionAttributeValueSetId and passing container variable containing Dimension attribute and its value. After doing this, I found out that this class has become obsolete and it is no longer supported.

So, I dug into the Dimension classes in D365 and able to fullfill the requirement with following piece of code:

LedgerDefaultDimensionValueSet generateDefaultDimension(str _costCentre)
{
List dimensionValue = new List(Types::Class);

DimensionNameValueListContract dimensionNameValueListContract = new DimensionNameValueListContract();
DimensionStorageResult dimensionStorageResult;
DimensionAttributeValueContract dimensionAttributeValueContract;

//#CostCentre is the macro for the name of CostCentre dimension attribute

dimensionAttributeValueContract = DimensionAttributeValueContract::construct(#CostCentre, _costCentre);
dimensionValue.addEnd(dimensionAttributeValueContract);

dimensionNameValueListContract.parmValues(dimensionValue);

dimensionStorageResult = DimensionNameValueListServiceProvider::newForDimensionNameValueListContract(dimensionNameValueListContract).resolve();

return dimensionStorageResult.parmSavedRecId();
}

inventJournalTrans.DefaultDimension = generateDefaultDimension(“8099”);

In the above method, I have passed cost centre financial dimension value and returning DefaultDimension RecId. Later on, I assigned it to the InventJournalTrans record to update the finacial dimension value with the new cost centre value.

Enjoy DAXing.

Advertisements

Recently, I was working on a customization for AP – > Payments report (Accounts payable -> Payments -> Payment journal -> Lines -> Print -> Payments and I noticed that the report is not filtering the data correctly based on the filter criteria specified using SysQuery form as shown below for Account number 1001:

Image1

Image2

As you can see from the above output that report is showing the records against Account number 1002 as well, whereas I have selected 1001 from SysQuery form. I, then dig into the code and found that the code is not taking the report query with filter criteria applied and hence the data isn’t showing correctly on report.

To resolve the above issue, I have made a small change to retrieve the report query which contains the filter criteria user selected on the form and then this query gets inserted in the Query contract map as shown below:

Image3

Now run the report and you should see the filtered results on the report based on the criteria defined under SysQuery form.

 

Recently I performed an upgrade from AX 2012 FP to AX 2012 R3. After that, beside normal X++ code merging, I had to resolve conflicts in SSRS reports as well which is very complicated just because there is no official tool available from Microsoft to merge different layer changes for SSRS reports.

The steps I have tried to merge var layer changes in one of the SSRS reports is described below. The report is Vendor accrued purchases report.

  • Below is the SSRS report precision design before resolving any conflicts. The highlighted area below are the var layer changes. As I modified this report, so I know where the exact changes are. If you are not the original developer of the report, it would be very hard to figure out where the var layer changes are on the report design from the compare tool.

Image1

Also note down any additional data source, added on the report and its query. In my case, I have added one data source, so I noted down the name of the datasource and its query.

  • Now, copy the highlighted area shown above in a new report project so that we can copy this part from there later on. Create a new Dynamics AX report model project in Visual Studio and add a precision design to it as shown below:

Image2.jpg

Right click the Designs node under report model project, click Add -> Precision Design to add precision design to the report. Double click the precision design node to open the designer. Now copy the var layer changes shown in the first step on this precision design. Below is the screen shot of the var layer changes copied on the new report design:

Image3

  • After copying the var layer design changes to the new report project, we will now delete the var layer changes from the SSRS report in AX client. Once we delete the var layer changes, only sys layer changes will left which is part of AX 2012 R3 code. Close the reporting project in Visual Studio which contain the design changes for both var and sys layer. Right click on VendAccruedPurchases_NA report under SSRS reports node in AX and select Delete to delete var layer changes.

Note: Before deleting var layer changes, make sure that you export the changes in XPO file in case if you want to refer to it later on.

  • After the changes have been deleted, open the report in Visual Studio. Open the precision design by double clicking on the precision design name under Designs node. You will see that the var layer design changes are no longer there as shown below:

Image4

Now copy the var layer changes from the new report model project that you created earlier and paste it inside the body section at the same location where it was before. Extend the body section and drag the Tablix control to the bottom to make room for var layer design changes. Copy the var layer design changes from the new report project as shown below:Image5

Paste the var layer design changes into the empty body area inside the existing report design as shown below:

Image6

After the design is pasted

Image7

The highlighted portion above is the var layer design changes which I copied from the new report model project.

  • Now add the Dataset which was part of the var layer changes under report Datasets node. Give it the same name and specify the query for the dataset which you noted down in Step 1.

Above steps works for simple var layer design changes, but if var layer changes are quite complex and not easy to identify, then it would be better to run the compare tool on the report design and note down some of the major differences between var and sys layer changes. Then copy those design changes to the new report project and paste it to the existing report design afterwards on top of sys layer changes.

I hope this tip will help in merging SSRS reports with simple design changes.

 

Recently, I came across an strange issue after doing model store deployment on client’s LIVE environment. Our client uses Dynamics Anywhere portal to run the production receipt process. After deployment, following error was thrown from \Data Dictionary\Tables\InventModelGroupItem\Methods\modelGroupNoThrow method when the receipt process is trying to create new pallet records, though the record was there in the table.

If the ModelGroupId field is not blank, there must be a record in the InventModelGroup table. If the record is not found, make sure the user has permission to perform a cross-company select on this table. The security framework will allow the select statement to return records for the companies in which the current user has explicit access of the tables involved. Therefore, it will return 0 records if the user does not have explicit access to the tables even if the tables are not AOSAuthorization-protected.

Interestingly, this error was not showing in TEST and REGRESSION environments. We can’t see any obvious reason why the above error message was only showing in LIVE and not in TEST. Then I found out that the code in the above method has been changed in later CUs for AX 2012 feature pack and in AX 2012 R3 as well. I worked with MS to get the hotfix which made the changes in this method. The hotfix code commented out the error message and made a second attempt to retrieve InventModelGroup item without crosscompany keyword. So, I though that this should resolve the issue, because the error message has been commented out and record is being retrieved in a different manner.

I did the deployment with hotfix code and bang! we got the same error message again. I was scratching my head and thinking, from where the error message was coming, because that was the only place from where the error message was coming and we had replaced it with the new code which doesn’t throw any error message. We did 4, 5 attempts of deployment with different steps in different sequence but in vain. Then I found a blog which mentioned similar issue related to BC session. After this, I decided to flush AOS cache using the instructions described in this blog post. There are three AOSes for client’s LIVE environment, so I performed the following steps:

  1. Start one AOS after deployment.
  2. Flush AOS cache using the instructions in the blog post, I mentioned above.
  3. Start other AOSes.

After doing the above steps in the sequence, I managed to resolve the issue and the error is gone. So, finally the BC session created through Dynamics Anywhere able to pick up the latest CIL code. Afterwards, I searched in LCS for this issue and found the following hotfix:

KB 2936094 SysGlobalObjectCache is not invalidated in multi AOS environment for common intermediate language (CIL) code

I checked with Microsoft about the above hotfix and technical support person confirmed that the above hotfix is addressing the same issue I described above. I didn’t know about this hotfix, so I ended up spending so many days and nights to resolve this issue.

Hope it will help other people who are facing the same issue.

Enjoy Daxing.

 

 

 

 

During the last 6 months, I have been extensively working on SSRS reports, so based on my experience in SSRS reports development, I have compiled together the list of Tips and Tricks which would help AX developers to expedite the report development and saving them heaps of time. Below is the list:

  • If the data on the new field is not showing, when you run the report, then try to refresh cache from Tools – > Cache option and then run the report.
  • If the new field is not showing under report’s dataset after refresh, then verify the following things:
  • Check if the default client configuration is pointing to the AOS instance you are working on.
  • Check if your VS instance is connecting to the right AOS instance. To find which report server instance, VS is connecting to, try to deploy the report from Visual studio, and then check the message window. The deployment information shows the AOS and the report server instance the report is being deployed. Example shown below:

Deploy reports message

If the above report server location doesn’t looks correct, then you may need to change the default client configuration.

  • If the report is not getting deployed to the correct instance, then you may need to change the default client configuration. For example, if you are working in DEV environment, change the default client configuration to the DEV and vice versa.
  • If you have changed the SSRS report query and the changes are not appearing on the report parameter form, then try to do the following things:
  • Delete usage data.
  • Delete report related data from SRSReportQuery
  • Refresh cache from Tools -> Cache options. Use all four options.
  • If you want to move a control either text box or rectangle control or any other control from keyboard slightly towards any direction, then use the arrow key with the combination of Ctrl key.
  • If address is appearing on multiple lines, then use the Replace function to remove line feed. Example shown below:

          Replace(First(Fields!CompanyAddress.Value,”PurchPurchaseOrderDS”),Chr(10),”, “)

  • If the data in some fields on header or footer is truncating, then increase the size of the header or footer, because header and footer section does not auto grow.
  • If you have to develop a new report and some of the sections is similar to one of the existing report, then you can open the report designs side by side and copy paste the sections from existing design to the new one. After doing this, make sure you rename the control in your new design, otherwise you would get errors during report deployment. The duplicate name errors will not be shown when you build the report project or add the project to AOT. Also, change the name of dataset in field’s expression.
  • If you want to do the complete redesign of an existing report, then it is better to copy the existing design and create a new design with another name. The advantage is that you can always refer back to the old design for field’s references and positions and also you can see the report’s output based on the old design. You don’t have to go to another environment to check the standard report design. After, you completed developing the report, you may need to update the ‘Name’ column in PrintMgmtReportFormat See example below for free text invoice report:

PrintmgmtReportformat

Say, your new report design name is Report_INT, then you need to update the Name column to FreeTextInvoice.Report_INT. This is not a global table, so you may need to change this record for each company where you intend to use this report. If there are too many companies to update manually, then you can write a job to update this based on the DocumentType column.

  • If you add a new field in report’s table in AX, refreshing the dataset in VS brings that new field in report’s dataset. Before using that new field in your report design, you need to

close the design and reopen it again and then only you would be able to refer to the new field in your report design. Sometime, you spend lot of time searching for the new field which is showing under report’s dataset, but not appearing in report design, when you select the related dataset under report design.

  • Always export the report as PDF to view the output and verify the formatting as per requirements, as AX report viewer output uses HTML renderer so it is not the output you are going to see when you print the report on printer.
  • When preparing the development estimates for static reports, include 1 or 2 hours additional time just for report’s deployment. Sometime, it takes around 4 to 5 minutes to deploy a static report. The details of which reports are static can be found on the following form:

System administration -> Setup -> Business intelligence -> Reporting Services -> Report deployment settings

  • When you are modifying a report which is static, then it is better to make most of the changes in one go and then deploy the report to see the output instead of making small changes one by one and check the output. This is just to save the time because static report deployment takes lot of time.
  • If on PDF output of the report, the image is not displaying correctly, then most probably it is due to the fact that the image is in png format. Select the image with JPEG format and then it should work. PDF renderer doesn’t support images with PNG format.
  • Always try to put the report items in containers such as rectangle. This will help control the way, report items are displayed on the report page.
  • If you are getting errors related to any expression used in the controls while compiling the report project in Visual studio and you don’t know which control it is related to, then one way to find out is to search the report RDL for the error text and then look at the parent XML node to see which control it is related to. Just press Ctrl+F on your report design to search the entire solution for the error text and it opens the report RDL in XML format.
  • If you have removed any vertical spacing between textboxes on report design, but still when you run the report, there is spacing between the text boxes, then try to decrease the top and bottom padding for the textboxes accordingly. This will reduce the spacing between control showing at run time.
  • If you want to display the text on reports in ALL caps, but there is no label exist with upper case, then don’t create new upper case labels, instead use UCASE function in report

with existing labels and then it will be displayed on the report in upper case. Example shown below:

                     Ucase(Labels!@SYS26401)

  • If the positions of textboxes or tablix in your report output is not showing as expected, then set the background colour of the controls to certain colour and check the output. You can get an idea of what is exactly happening when the report is rendered.
  • For static reports, if you have changed the label text which is used in the report, then you have to deploy the report again to see the updated label, because the label are resolved at the time of deployment for static reports.
  • If your report item not being displayed on the location where it should be, then most probably the reason would be that other control is expanding and pushing that item further down, so either set the auto grow to false or leave appropriate width or height at design time
  • If your reports are not deploying to the correct reporting server when you are deploying it within AX environment, then a quick workaround is to deploy the report to specific report sever using the following power shell command:

Publish-AXReport –id ReportConfigurationID –ReportName ReportName

Example shown below:

Publish-AXReport –id AXPROD –ReportName PurchPurchaseOrder

You can find the report configuration ID on the report servers form. The path is mentioned below:

System administration -> Setup -> Business intelligence -> Reporting Services -> Report servers.

Enjoy Daxing.

Hi,

Recently, one of our client reported an issue where they were trying to export the report to Excel from report viewer window in AX and that was taking forever to complete. After trying different things, I looked at the AOS even logs and found below error message there:

Object Server 01:  An error has occurred in the services framework.  Method: AifMessageInspector::AfterReceiveRequest.  Error: System.ServiceModel.FaultException: Failed to logon to Microsoft Dynamics AX.

So, I added the business connector proxy account as a user in AX and assign System administrator and System user roles to that. You can find the BC user for your AX environment under System services account form. Below is the path for the form:

System administration -> Setup -> System -> System service accounts.

Cheers,

Baber.

Hi All,

Today, I was getting below error while running the batch class as a batch job in AX 2012:

Unable to construct an object from the class “MyClassName” in the batch framework. Make sure that the X++ code has been compiled to Microsoft .NET Framework CIL, and that the constructor does not require any parameters

All the solutions I found was suggesting to perform either incremental or full CIL, but it didn’t resolve the issue in my case. Then I restarted all the AOSes for my environment and voila, the error was gone.

So, if you get this error and incremental or full CIL doesn’t resolve the issue for you, then try restarting all the AOSes.

Thanks,

Baber.

ReArm your AX 2012 VMs

Hi,

Have you ever get a problem where your Windows sever license of your AX 2012 VM get expired? If yes, then you need to rearm your Windows license on your VM. Here is how to do this.

Open command prompt on your VM and type slmgr.vbs -rearm. Reboot the machine afterwards and you will get the license for another 365 days.

Enjoy!

When you install CU 7 on AX 2012 R2, unexpected compile time errors occurs on the following forms:

compile errors.

Below link explains how to resolve this issue:

http://blogs.msdn.com/b/axsupport/archive/2013/11/06/unexpected-compiler-errors-installing-cumulative-update-7-for-microsoft-dynamics-ax-2012-r2.aspx

I came across an issue while trying to send emails using email distributor batch job in AX 2012. If 10 entries are created in email sending status form, only one of them is emailed and rest of them were failing. I have found the reason for this in LCS and the reason is mentioned below:

SysEmailDistributor can only send one email with same attachment name in batch due to WinApiServer::FileDelete not removing files when called in common intermediate language (CIL).

Microsoft has confirmed that this is an issue, but they are not fixing at this time. More details can be found at the following link:

https://fix.lcs.dynamics.com/Issue/NotFixed/313591?bugId=1651803&qc=baf7c6ff636fd40738c7cc6618d53fce

So, the only resolution is to have different file name for your email attachments. For instance, if you are sending sales order invoice to your customer, you can have the sales order invoice number as your attachment file name.