Tuesday 30 October 2018

Refreshing code changes in reports objects in SSRS

When working with the reports' objects (be that one of the controller, contract, data provider classes, the query, or the table, temp or regular) sometimes it happens that the changes done are not properly reflected in SSRS.

The first item that I want to make clear is that for the reports you do not need to run the generate CIL (be that full or incremental) when doing changes in the above objects. It is a misconception that doing this will fix any problems with the SSRS, and not doing this will save you the time of waiting for it. Of course, there is the time when the reports are not running all together, but that is when the system services are not properly running to serve information regarding the session, query, or metadata.

With that in mind, you have the following items to perform:
1. if you are on R3, you have the Tools -> Caches -> Refresh report server;
2. also, do a Tools -> Caches -> Refresh elements and Tools -> Caches -> Refresh dictionary;
3. if you have an AOT query, you can do a Restore on the query;
4. open the report in Visual Studio, and perform a Refresh on your dataset in the Datasets node;
5. also in Visual Studio perform a rebuild and a deploy of the report;
6. before step 5. you can check that the parameters you have for your report are the proper ones (if you've changed the data contract or the query);
7. depending on the decision to load the last values (controller.parmLoadFromSysLastValue) you want to do a Reset usage data;
8. and last but not least, you want to do a Restore and then also a Deploy element on the report in the AOT.

You should view your new changes now (in the dialog prompt or the report).

Monday 22 October 2018

AX2012: Error when downgrading the AX server kernel

Description:
 It can happen that you need to downgrade the AOS kernel in a system. Depending on the build you are going back to, you might get an error message.

Error message:
Object Server 01:  Fatal SQL condition during
login. Error message: “The internal time zone version number stored in the
database is higher than the version supported by the kernel (4/1). Use a newer
Microsoft Dynamics AX kernel.”
Solution:
You need to change the value for the column value SYSTIMEZONESVERSION in the table SQLSystemVariables. If you look in
the event viewer you can see that it finds the value 4, but expected 1 (4/1).
So the solution is to change the value to 1.

Tuesday 16 October 2018

Create a Simple Batch Job

In this post we’ll learn how to create a very basic custom Batch job using SysOperation framework. We’ll use the base controller class SysOperationServiceController and develop a custom service operation class to achieve the goal.
Requirement:
To create a Batch job to mark all the records as processed in a custom table MAKSalesTable.
Project overview:
Untitled
The project shows how simple yet powerful the SysOperation framework is for developing custom batch jobs as opposed to RunBase framework since the minimum development needed to create a fully functional batch job is to create a custom service operation class defining a single method giving the implementation for the batch operation to be performed.
Development steps:
1. Create a service operation class MAKSalesTableService having the following class declaration:
class MAKSalesTableService
{
}
2. Create a new method in the class giving a suitable name like processRecords having the following definition:
[SysEntryPointAttribute(false)]
public void processRecords()
{
    MAKSalesTable   makSalesTable;
    int             counter = 0;

    //Determines the runtime
    if (xSession::isCLRSession())
    {
        info('Running in a CLR session.');
    }
    else
    {
        info('Running in an interpreter session.');

        //Determines the tier
        if (isRunningOnServer())
        {
            info('Running on the AOS.');
        }
        else
        {
            info('Running on the Client.');
        }
    }

    //Actual operation performed
    while select forUpdate makSalesTable
    {
        ttsBegin;
        makSalesTable.Processed = NoYes::Yes;
        makSalesTable.update();
        ttsCommit;

        counter++;
    }

    info(strFmt("Successfully processed %1 records.", counter));
}
3. Create an action menu item MAKSalesTableService pointing to SysOperationServiceController.
4. Set the parameters of the action menu item to the service operation just created, MAKSalesTableService.processRecords.
Untitled
5. Compile the service operation class and generate incremental IL.
6. Click on the action menu item to run the batch job. Check the Batch processing checkbox to run the job in CLR runtime which is the batch server execution environment.
Untitled
Untitled
7. Click System administration > Inquiries > Batch jobs to view the status of the job. You may also click on the Log button to view the messages written to infolog during the job execution.
Untitled
Untitled
Preconditions:
Before running the batch job, all the records were unprocessed:
Untitled
Post conditions:
After running the batch job, the list page shows that all the records are now marked as processed:
Untitled

Changing the Background Color on AX Forms in AX 2012

I recently wrote some additions to a nice little utility that changes the background color in forms.  For each company you can set the background color to a different color of your liking.  The color serves as a visual reminder of which company you are currently logged into.  Enjoy!

Addendum:  I just added a project that does the same for AX 2012 R2.  No additional functionality, just made it compatible with AX 2012 R2.  The download is now a zipped file that contains a project for AX 2012, and AX 2012 R2.  Please import the correct project for your version..

Monday 10 September 2018

An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database

Steps today are
1. httpRuntime executionTimeout
added executionTimeout to ...\Reporting\web.config Line now reads
<httpRuntime executionTimeout = "10800" maxRequestLength="51200" />
2. ASP Script timeout
increased this from 00:01:30 to 00:05:00
IIS Manger -> server -> sites -> Sharepoint Web Services. find the reporting service by right click -> Manage Application -> Advanced Settings -> Physical Path. Then open ASP in right pane, expand Limits properties, Script Time-Out click apply (top right pane)
3. Changed processing options on individual reports
5.45am Report - processing timeout changed to 3600 (was previously default value)
5.53am Report - processing timeout changed to never (was previously default value)
4. Stopped and Restarted IIS
__________________________
Browse the reporting service -> site setting -> general tab -> change the time out value

Making Price to 4 decimals


First make price EDT to 4 decimal then 
General Ledger ->Setup->Currencies->currency

select the currency and make the rounding rule to 0.0001

Access denied to method validateDataContracts in class SysOperationFarmeworkService AX 2012

The permission is included in AifEssentials privilege and the privilege is normally included in SystemUser role (through SysServerAXBasicMaintain duty). Therefore it seems that you forget to add the user to SystemUser role.

Read-only DocuRef form for Auditors

The most common problem encounters while auditing period in companies is not to allow auditors to attach or delete attachments from DocuRef form. However, there is no out of the box role in AX, but it can be achieved with small customizations and by applying the modified duplicated copy of system role and privilege.

STEP 1


Make duplicate copy of “SystemUser” role and “DocumentHandlingEssentials” privilege. In my case, I have duplicated with the name “MySystemUser” and MyDocumentHandlingEssentials”.

STEP 2

In “MyDocumentHandlingEssentials” remove all entry points accept “DocuView”.

STEP 3

Now assign “MyDocumentHandlingEssentials” privilege to “MySystemUser” role and make sure“DocumentHandlingEssentials” is not overriding it.

STEP 4

Now go to “DocuView” form and change the “NeedPermission” property for both “New” and “Delete”command buttons to “Delete”.



You are done with the changes, now assign this customized “MySystemUser” to Auditor user and remove the default “SystemUser” role.



Note: In some AX builds you may find a privilege with name “ClientEssentials”, it too contains all“DocuRef” entry points, so if you find one in your build, apply the same process of duplicating and removal of all “DocuRef” related entry points from it. 

User and roles report

There is a query in AX called SysSecRolesForUser that gives this data. You can simply create a view from it and export to excel.

Thursday 9 August 2018

Microsoft Dynamics AX Error: The Record Already Exists

I was recently working on an issue in Dynamics AX where, after a code move we started receiving the error: ‘Cannot create a record in “TableName.” The record already exists.’
One of the most common reasons for this error is, one of the unique index fields has duplicated value. I verified all the unique index requirements were satisfied and there were no duplicated index values.
After investigating, I found out that the RecId generated by the system was getting a value that has been previously used.

The RecId sequence for tables is stored in SystemSequences table and can get out of sync due to one/more of the following reasons:

1.       Data is inserted in the SQL database directly
2.       There has been tableId conflicts during model store move
To fix this error, we need to reset the NextVal field in SystemSequences table. NextVal field should be set to a value greater than the max RecId of the table.

Steps to resolve the error ‘record already exists’:

1.       Get the tableId for the table.
a.       You can find the tableId from AOT, under Properties for the table.
Cust Tablesyste
b.      You can run a job to display the tableId in infolog.
Get table from table name
2.       Open SQL Server Management Studio and get the max value for RecId for the table, from SystemSequences table.
3.       Update the NextVal field to a value greater than the max RecId of the table.
4.       Restart the AOS.

Monday 26 March 2018

Contact Me ‘CDO.Message’ returned error code

When we use the Dynamics AX to send email, sometimes we will run into an CDO.Message issue with error message Method ‘send’ in COM object of class ‘CDO.Message’ returned error code 0x80040211 () which means: .
The error codes listed below are really useful when troubleshooting the issue:
Value Remarks 0x80040201
Exception %1 was generated at address %2. 0x80040202 No data source has been opened for the object.
0x80040203
The object does not support this type of data source.
0x80040204
The object does not support the requested property name or namespace.
0x80040205
The object does not support the requested property.
0x80040206
The object is not active. It may have been deleted or it may not have been opened.
0x80040207
The object does not support storing persistent state information for objects.
0x80040208
The requested property or feature, while supported, is not available at this time or in this context.
0x80040209 No default drop directory has been configured for this server.
0x8004020A
The SMTP server name is required, and was not found in the configuration source.
0x8004020B
The NNTP server name is required, and was not found in the configuration source.
0x8004020C
At least one recipient is required, but none were found.
0x8004020D
At least one of the From or Sender fields is required, and neither was found.
0x8004020E
The server rejected the sender address. The server response was: %1
0x8004020F
The server rejected one or more recipient addresses. The server response was: %1
0x80040210
The message could not be posted to the NNTP server. The transport error code was %2. The server response was %1
0x80040211
The message could not be sent to the SMTP server. The transport error code was %2. The server response was %1
0x80040212
The transport lost its connection to the server.
0x80040213
The transport failed to connect to the server.
0x80040214
The Subject, From, and Newsgroup fields are all required, and one or more was not found.
0x80040215
The server rejected the logon attempt due to authentication failure. The server response was: %1
0x80040216
The content type was not valid in this context. For example, the root of an MHTML message must be an HTML document.
0x80040217
The transport was unable to log on to the server.
0x80040218
The requested resource could not be found. The server response was: %1.
0x80040219
Access to the requested resource is denied. The server response was: %1.
0x8004021A
The HTTP request failed. The server response was: %1.
0x8004021B
This is a multipart body part. It has no content other than the body parts contained within it.
0x8004021C
Multipart body parts must be encoded as 7bit, 8bit, or binary.
0x8004021E
The requested property was not found.
0x80040220
The “SendUsing” configuration value is invalid.
0x80040221
The “PostUsing” configuration value is invalid.
0x80040222
The pickup directory path is required and was not specified.
0x80040223
One or more messages could not be deleted.
0x80040227
The property is read-only.
0x80040228
The property cannot be deleted.
0x80040229
Data written to the object are inconsistent or invalid.
x8004022A The requested property is not in the mail header namespace.
0x8004022B
The requested character set is not installed on the computer.
0x8004022C
The ADO stream has not been opened.
0x8004022D
The content properties are missing.
0x8004022E
Content properties XML must be encoded using UTF-8.
0x8004022F
Failed to parse content properties XML.
0x80040230
Failed to convert a property from XML to a requested type.
0x80040231
No directories were specified for resolution.
0x80040232
Failed to resolve against one or more of the specified directories.
0x80040233
Could not find the Sender’s mailbox.
0x80040234
Binding to self is not allowed.
0x80044000
The first argument is invalid.
0x80044001
The second argument is invalid.
0x80044002
The third argument is invalid.
0x80044003
The fourth argument is invalid.
0x80044004
The fifth argument is invalid.
0x800CCE05
The requested body part was not found in this message.
0x800CCE1D
The content encoding type is invalid.