Leader Board

Passing Parameters to a Report in Dynamics AX

Passing Parameters to a Report in Dynamics AX « Rehan Aqeel's Blog:


Creating reports in AX is generally ‘a walk in the park’ even for the new developers not fully acquaint with the syntax of X++. However, it sometimes becomes challenging to understand how the parameters could be passed to a report when you want to initiate that report from a form.

Let’s look at an example where you may want to create a ‘Purchase Requisition Report’ that the users could generate to see the status of each purchase requisition and the associated workflow entries for that Purchase Requisition.
I will not go into the details of how to develop this report, but you should know that such a report do not exist in the out-of-the-box functionality within AX 2009.
So let’s say that you have developed this report and now when you generate this report you can pass on the required ‘Purchase Requisition ID’ in the ‘Parameter Prompt’ of the report to view the particular PR details accordingly.
However, now in the next step you want to call this report from the ‘Purchase Requisition Form’ (i.e PurchReqTable). To do this, you should first create a ‘Button’ within the ButtonGroup on the form.
Now right-click on the ‘Methods’ node within the newly created button and choose ‘Override Method –> clicked’
Within the clicked function, you should write the following code;
void clicked()
{
Args args = new args();
ReportRun reportRun;
;
args.parm(PurchReqTable.PurchReqId);
args.name(reportstr(PurchRequisitionDetails));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();
//hello
super();
}
The above code calls the args() system class. This class is used to pass arguments to a class-constructor. You can pass information such as name, caller, and parameters to a new class. This code passes the relevant Purchase Requisition ID (which is currently selected by the user on the form) to the report ‘PurchRequisitionDetails’ in the above code.
Now, you need to go to the report (which in this case is PurchRequisitionDetails). Right-Click on the methods node of the Report and click on ‘Override Method –> init’
In this init method, you need to enter the following code to allow the report to read the parameters from the form.
public void init()
{
;
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(PurchReqTable))
.addRange(fieldnum(PurchReqTable, PurchReqId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info(“Error in init method”);
}
}
Once you have got the above code correctly entered, you should now be able to generate your report directly from the form.

Document Handling in AX – setup and Example

Imparted from Here

Some initial setups for enabling document handling in AX-

On the Tools menu, select Options.
Under Document handling, select Document handling active.
Select Update toolbar line button to highlight the Document handling icon on the toolbar when you select a record with documents references.

Documents are stored in a default document archive directory and before you start creating documents, you must select the location in theParameters form.

Click Basic > Setup > Document management > Parameters.
In Archive directory, type the path to the archive directory, or use the browse button () to select a folder on your network.
Select the Number sequences tab.
In the Number sequence code list, select the number sequence to use for naming your documents.

The document management system handles several types of documents including letters, worksheets, and simple notes. Before you can create documents of a certain type, the document type must be created in the Document type form.

By default, all documents are stored in the Archive directory selected on the Parameters form. However you can select alternative folders for the individual document types.

Also by default, all document types are available from all forms, but some document types are only relevant for certain tables, such as, if you only want to create customer letters for records in the Customers form. When you associate a document type with a specific table, it is not possible to create any documents of that type, in other tables.

Create new document type

Click Basic > Setup > Document management > Document types.
Press CTRL+N to create a new document type.
In Type, type a code for the document type.
In Name, type a descriptive name for the document type.
In the Job description list, select the type of document to create.
In the Group list, select a group for the document type.

Now, I would like to explain document handling with an example for sales orders form of DOC type.

Initially set the parameters for document handling.

Go to – >Basic -> setup -> Document Management – > Parameters form

set the archive diretory path ( where the document has to be stored like c:\AxDocuments). Remember when ever u create document for a record, the document gets stored in the above location specified.

Check – use Active document table checkbox.

In the number sequences tab - select the number sequence you would like to use for the documents.

Then, If you want to enable documents for salestable – Go to – > Basic -> setup -> Document Management – > Active document tables form . Then select the name of the table here as salestable and in enable the always enabled checkBox.

Now when you open the salestable form you can find the document handling enabled on the toolbar for the salestable form. Double click the document handling icon and create a new document for that record by clicking the new button and selecting the Document menuitem button.Now you can create documents for the salestable.Once you create documents the documents will be stored in the archive path selected in the parameters form.

When ever u create a document, it hits docuref and docuvalue tables.

In the docuref,it creates a record with the tableid of the salestable, the record id of the salestable and the dataareaid ..etc..and correspondingly a record gets generated in the docuvalue with all the filenames, extensions,path etc

To view the documents in the salestable from itself, i mean in the gird itself here is the way…

Open the salestable form, Then , I would like to use icons for every record in the salestable.So i will write a display method at the salestable level.

//BP Deviation Documented
display smmDocIconNum
showDocHandIcon()

{
#macrolib.resource
;
if ((select firstonly docuRef where
docuRef.RefCompanyId == this.DataAreaId && docuRef.RefTableId ==
this.TableId && docuRef.RefRecId == this.RecId).RecId)

{
return #RES_NODE_DOC;
}

return #RES_AM_NEW;
}

Now create a new window control in the gird. Add the datasource as salestable and datamethod as showDocHandIcon.

The main class where all the business logic is written is docuAction Class. Now i am going to use this class to open the documents for the records.

Now please override the Mouseup() method of the window control

public int
mouseUp(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)

{
int ret;
args args;
docuRef
docuRef;

;
ret =
super(_x, _y, _button, _Ctrl, _Shift);

element.showDocument();
// Method at form level

return ret;
}

Now add showDocument() method at form level

void showDocument()
{
args args;
docuref docuref;
;

args = new args();
docuRef =
docuref::find(salesTable.dataAreaId,tablenum(SalesTable),salesTable.RecId,today());

args.record(docuRef);
args.parmEnumType(enumnum(Docucode));
args.parmEnum(Docucode::Open);
docuaction::main(args);
}

NOW YOU CAN VIEW YOUR DOCUMENTS FROM THE GRID ITSELF BY DOUBLE CLICKING THE WINDOW CONTROL.


Axapta Dialog Validation - Stack Overflow

Axapta Dialog Validation - Stack Overflow:

Here is an example in AX 2009 of how to build a simple dialog using the RunBase class. In it I create a class called DialogExample and derive from RunBase. To show the dialog you simply need to run the class, but typically this would be done by pointing a MenuItem at the class.

 

public class DialogExample extends RunBase

{

DialogField dialogName;

Name name;

#DEFINE.CurrentVersion(1)

#LOCALMACRO.CurrentList

name

#ENDMACRO

}

Object dialog()

{

Dialog dialog = super();

;

// Add a field for a name to the dialog. This will populate the field with

// any value that happens to be saved in name from previous uses of the

// dialog.

dialogName = dialog.addFieldValue(TypeId(Name), name);

return dialog;

}

boolean getFromDialog()

{

;

// Retrieve the current value from the dialog.

name = dialogName.value();

return true;

}

boolean validate(Object _calledFrom = null)

{

boolean isValid;

isValid = super(_calledFrom);

// Perform any validation nessecary.

if (name != 'abc')

{

isValid = checkFailed('Name is not equal to abc') && isValid;

}

return isValid;

}

Name parmName()

{

;

return name;

}

public container pack()

{

return [#CurrentVersion,#CurrentList];

}

public boolean unpack(container _packedClass)

{

int version = conpeek(_packedClass, 1);

switch (version)

{

case #CurrentVersion:

[version,#CurrentList] = _packedClass;

break;

default : return false;

}

return true;

}

public static void main(Args args)

{

DialogExample DialogExample;

;

dialogExample = new dialogExample();

// Display the dialog. This only returns true if the the user clicks "Ok"

// and validation passes.

if (dialogExample.prompt())

{

// Perform any logic that needs to be run.

info(dialogExample.parmName());

}

}

 

Typically in this scenario logic that needs to be run would be put in a run method on the

class and then called into from main if the Ok button is clicked.

Since the run method would be an instance method this gets rid of the need for the parm methods to access the value of the field on the dialog.

Managing the Batch Server Execution Process

 

Imparted from Inside MS Dynamics Ax 2009

Before a batch job can be executed on an AOS, you must confi gure the AOS as a batch server
and set up the batch groups that tell the system which AOS needs to execute the job. In
addition to these initial confi guration duties, you’ll likely need to manage the batch tasks and
jobs: checking status, reviewing history, and sometimes canceling a batch job. You’ll probably
need to debug a batch task at some point as well. In the following section, we describe how
to confi gure an AOS as a batch server, set up batch groups, manage batch jobs, and debug a
batch task.

Set Up Server Confi guration
You can confi gure an AOS to be a batch server, including specifying when the batch server
is available for processing and how many tasks it can run, using the Server Confi guration
form. The Server Confi guration form is in Administration\Setup\Server Confi guration. Note
that the fi rst AOS is automatically designated as a batch server. Figure 16-5 shows the Server
Confi guration form.

Tip  Use multiple batch servers to increase throughput and reduce the amount of time it takes to
run batches


1. On the Overview tab, select a server.
2. Select Is Batch Server to enable batch processing on the server, as shown in Figure below

image

3. On the Batch Server Schedule tab, enter the maximum number of batch tasks that can
be run on the AOS instance at one time. The server continues to pick up tasks from the
queue until it reaches its maximum.
4. Enter a starting time in the Start Time field and an ending time in the End Time field to
schedule the batch processing. Press Ctrl+N to enter an additional time period.

Tip It’s a good idea to exclude a server from batch processing when it is busy with regular
transaction processing. You can set server schedules so that each AOS is available for user
traffic during the day and for batch traffic overnight. Keep in mind that if the server is
running a task when its batch processing availability ends, the task continues running to
completion. However, the server doesn’t pick up any more tasks from the queue.

On the Batch Server Groups tab, use the arrow buttons to specify the batch groups that
5. can run on the selected server.

Resource Page for SSRS and SSAS Integration in Microsoft Dynamics AX 2009

Imparted from here

This page is intended to provide a consolidated list of published documentation, known issues, solutions as well as tips and tricks for SSRS and SSAS integration in Microsoft Dynamics AX 2009.

Important Note: Many of the links on this page go to CustomerSource. Learn more about CustomerSource and how to sign in

The default OLAP cubes that are provided with Microsoft Dynamics AX were designed with full license and configuration keys. When using License and Configuration Keys where all modules are not present, OLAP cubes will be need to be configured. If any license or configuration key is turned off, you must complete the procedures in the Microsoft Dynamics AX 2009 White Paper: Configuring the Default OLAP Cubes.

The Enterprise Portal Role center pages contain SSRS reports and SSAS default cubes. If you have not implemented the SSRS or have not completed your Dynamics® AX customizations you may want to consider removing the SSRS web parts from Enterprise Portal or selecting the Default Role Center which does not have BI content. Implementing the reporting features can be done at a later time after the main implementation is complete.

When setting up SSRS, SSAS, and WSS or MOSS on multiple severs you will need to be aware of how to set up and configure Kerberos Authentication. See the Microsoft Dynamics AX 2009 White Paper: Configuring Kerberos Authentication with Role Centers and the common problems section below.

On this page:

Top Downloads

Top

Prerequisites - Installation and Setup

A number of the common issues can be resolved by ensuring that the prerequisites have been properly installed on the correct servers and by carefully reviewing the installation and troubleshooting documentation before attempting the actual installation.

Top

Featured Videos

Top

Related Resources

Top

Common Problems & Solutions

This section lists the most common issues encountered when building the integration between Microsoft Dynamics® AX, SSRS and OLAP and the solution recommended by the Microsoft Dynamics® AX Support team.

Issue

Error trying to deploy reports:
Microsoft Dynamics AX Reporting Project Deployment: The following components have not been installed or are not configured correctly: AL.exe

Solution

Download and install the Windows SDK for Windows Server 2008 and .NET Framework 3.5 Ensure it is fully installed.
Note: Install regardless of operating system

Issue

Error trying to deploy reports
System.InvalidOperationException: The following components have not been installed or are not configured correctly: Microsoft Domain-Specific Language Tools

Solution

Download and install these required components. Microsoft Visual Studio 2008 Shell (isolated mode) Redistributable Package

  1. Save the download locally .
  2. Extract the package.
  3. Run the vs_appenvredist.msi
    Note: Install regardless of operating system

Issue

Error trying to deploy reports
Microsoft Dynamics AX Reporting Project Deployment: ClrBridgeLoader: fatal error :
Microsoft.Dynamics.ClrBridge.dll cannot be loaded. Fatal error: ClrBridge is note loaded.

Solution

Ensure you are trying to deploy reports from the SSRS server and that you can validate the SSRS server name in the Reporting Servers from within Microsoft Dynamics AX 2009. If this error appears right after installing the reporting extensions, launch the report deployment tool again.

Issue

Enterprise Portal (EP) or SSRS Reports don’t run or stop working
An attempt has been made to use a data extension 'AXDATAMETHOD' that is not registered for this report server. (rsDataExtensionNotFound)
or
data extension 'AXQUERY' and 'AXADOMD'

Solution

Installing or Reinstalling Reporting Extensions will resolve this issue. As a precaution make a Backup of:
Program Files\Microsoft SQL Server\MSSQL.<Instance>\Reporting Services\ReportServer folder

Note
: SSRS updates or Service Packs may remove entries from rsreportserver.config file.

Issue

Enterprise Portal (EP) Reports don’t run or stop working
A ProgressTemplate must be specified on UpdateProgress control with ID 'AxProgressControl'

Solution

You can resolve the issue by using one of the three methods below:

  1. Apply the hotfix from KB957312 to the RTM version.
  2. Upgrade to Microsoft Dynamics AX 2009 SP1.
  3. Un-install Microsoft .NET 3.5 SP1 and reinstall Microsoft .NET 3.5 without SP1

Issue

Report deployment tool crashes
Attempted to read or write protected memory. This is often an indication that the memory is corrupt

Solution

If multiple versions of Dynamics AX are installed on the same server you will need to change your AX 2009 Path in your environment variables ahead of your AX 4.0 path to avoid running the wrong version of DLL’s

Issue

Error running reports
Error during processing of 'AX_CompanyName' report parameter. (rsReportParameterProcessingError).

Solution

Process OLAP the cubes to supply data to the reports
or
An incorrect Execution account has been specified in the Reporting Services Configuration Manager
Note: For SSRS 2008 the Business Connector proxy account is required to be the SSRS service account and for SSRS 2005 the Business Connector Proxy account should be running as the SSRS application pool in IIS. Also look at application event log for details on other issues.

Issue

Enterprise Portal (EP) web site runs but not the reports in the EP web parts:
Dynamics Adapter LogonAs failed
or
Microsoft.Dynamics.BusinessConnectorNet.LogonFailedException

Solution

Leave the Execution account blank on SSRS 2005 or set to BC Proxy account on SSRS 2008 (Microsoft Dynamics AX 2009 SP1 only)
Note: SSRS Execution account is set to an account other than BC Proxy Account

Issue

EP or SSRS Reports don’t run or stop working
Dynamics Adapter LogonAsGuest failed
or
FatalSessionException...

Solution

The issue is caused by the Reporting Services web site set to anonymous Authentication. Changing the SSRS website to Integrated and/or un-marking Anonymous Authentication will resolve this issue.

Issue

Double Hop \ Kerberos Authentication
An Error has occurred while establishing as connection to the Analysis Server
or
Reports don’t display in the EP website from a Client Browser not local to the IIS server
Cannot read information from SQL Server Reporting Services. Validate that the Report Manager URL is correct

Solution

Setup Service Principle names (SPN) and Delegation to allow the passing of Kerberos certificate

References:

Issue

Office Data Connection (ODC) file deployment fails with SQL Server 2008
Microsoft Dynamics AX is searching for the SQL Server 2005 Microsoft.AnalysisServices.dll (v9.0.242.0)

Solution

Apply one of the following hotfixes:

  • For Microsoft Dynamics AX 2009 RTM: Apply the fix from KB957312
  • For Microsoft Dynamics AX 2009 SP1: Apply the fix from KB960158

If the hotfix does not resolve the issue, make sure you are running a Dynamics AX 2009 client on the EP web server when deploying the ODC files. As a workaround you can manually deploy the ODC files by following these steps:

  1. Click here to download a new ODC file (Dynamics_AX.odc).
  2. Save the ODC on the SSAS server.
  3. Open the ODC file with Notepad or any other text editor.
  4. Edit the odc file with the following changes:
    Data Source=OLAPServerName
    Initial Catalog=OLAPDbName
    Add SSPI=Kerberos after Initial Catalog if using Kerbersos (in red only required for Kerberos authentication)

    ….
    <odc:Connection odc:Type="OLEDB">
    <odc:ConnectionString>Provider=MSOLAP.3;Integrated Security=SSPI;Persist Security Info=True;
    DataSource=<Server1>;Initial Catalog=Dynamics AX;SSPI=Kerberos
    </odc:ConnectionString>
  5. Save the changed ODC file.
  6. Go to EP main site.
  7. Click Site Actions, and then click Site Settings.
  8. Under Galleries, click Master pages.
  9. Click View all site content (top left).
  10. Click Data Connections folder.
  11. Import the edited ODC file.

Issue

DataSet panel is missing in Report Designer when creating reports in Visual Studio Server 2008

Solution

For Visual Studio 2008, apply the fix in KB947173
OR
apply Microsoft Visual Studio 2008 Service Pack 1.

Issue

"Connection forcibly closed by remote host" in Dynamics setup log when trying to create an EP site in Microsoft Dynamics AX 2009

Solution

Download and install the Microsoft Analysis Management Objects:

Issue

"Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'"

Solution

Ensure SSRS service is running and are able to connect to instance via SQL Server Management Studio.
Note: Additional information can be found in SSRS error log.

Issue

Exception from HRESULT: 0X80041FFF

Solution

Change Visual Studio project location to local drive if using a network share

Issue

The Analysis extension is not seeing the SQL cluster name for Analysis Services when Analysis services is setup on a SQL cluster.

You will get an error similar to this when trying to install Analysis Extension in this environment:
Connecting to SQL Server 2005 Analysis Services on server 'SQL02' and instance 'MSOLAP$ANALYSIS'.
A connection cannot be made. Ensure that the server is running.
No connection could be made because the target machine actively refused it 127.0.0.1:2383
An error occurred while Setup was connecting to SQL Server Analysis Services instance 'MSOLAP$ANALYSIS' on server 'SQL02'.
An error occurred while Setup was connecting to SQL Server Analysis Services instance 'MSOLAP$ANALYSIS' on server 'SQL02'.

Solution

The workaround is to manually run the script to create the Dynamics AX OLAP db from the AX 2009 CD.
Navigate to this folder: \support\Analysis Services\Scripts on the Microsoft Dynamics AX 2009 installation CD.
Then run the dynamicsax.xmla script from within SQL Management Studio (connected to the SSAS instance).
This script will create the Dynamics AX OLAP database.

Issue

BC Proxy account fails to start for the SSRS reports in Enterprise Portal with RPC exception 5

When Enterprise Portal starts for the first time and displays SSRS reports, normally two Business Connectors are started. After a period of time or if the impersonated web user logs out for the SSRS Proxy account you may experience an RPC error 5 access denied and the SSRS reports will no longer display in Enterprise Portal.
Example Event Type: Error
Error:
Event Source: Dynamics .NET Business Connector 5.0
Event Category: None
Event ID: 180
Date: 10/7/2008
Time: 6:21:04 PM
User: N/A
Computer: AX2009
Description:
Microsoft Dynamics AX Business Connector Session 18.
RPC error: RPC exception 5 in Ping occurred in session 36

Solution

RPC error 5 can occur if the SSRS Execution account is set in the Reporting Services Configuration Manager. If the account used is the Business Connector proxy account the first startup of the Business Connector will work, but not any subsequent startups unless the IIS application pool if recycled or an IIS reset is done.
SSRS 2005
Remove the SSRS execution account through Reporting Services Configuration Manager and ensure the Business Connector account is running the IIS Application Pool for the SSRS web site.
SSRS 2008
Change the SSRS service to start as the Business Connector Proxy account and remove the SSRS execution account through Reporting Services Configuration Manager.
Note: Changing the SSRS account would require a change in the registered SPN’s if you are using Kerberos authentication

Top

Troubleshooting Tips

Top

Still having trouble...

If you are experiencing issues downloading the install file or documentation on CustomerSource/PartnerSource, please contact ITMBSSUP@microsoft.com

  1. Ask the community of users like yourself through the Microsoft Dynamics AX Community here.
  2. For Technical support questions, contact your partner, or if enrolled in a support plan directly with Microsoft, you can enter a new support request to Microsoft Dynamics Technical Support from CustomerSource or PartnerSource under Support >> New Support Request
    3. You can also contact Microsoft Dynamics Technical Support by phone using these links for country specific phone numbers:
  3. Partners – Global Support Contacts (requires PartnerSource login)
    Customers – Global Support Contacts (requires CustomerSource login)

Top

Acronyms used in this article
  • SSRS - SQL Server Reporting Services
  • SSAS - SQL Server Analysis Services (sometimes referred as OLAP)
  • OLAP - On-Line Analytical Processing
  • WSS - Windows SharePoint Services
  • MOSS - Microsoft Office SharePoint Server
  • BI - Business Intelligence
  • EP - Enterprise Portal
  • AMO - Analysis Management Objects (part of Microsoft SQL Server)

Imparted from here

Dynamics AX2009 Workflow - Checklist

 

Dynamics AX2009 Workflow - Checklist

I was going through the workflow implementation with a client recently and felt that there is a need of a check list for consultants/ users to configure the workflow and make it work or sometime troubleshoot the problems when it does not work. I have thought of the following points for the check list.

1. User options

a. Maintain the email address of the users .

image

b. Setup The parameters for receiving the notifications on the Notifications tab especially the two marked parameters for getting the notifications in client and or email.

image

2. Administration>Setup>Email parameters must be setup so that emails can be sent through AX.

image

3. Basic>Setup>Setting for workflow>settings for workflow to be used by the system to send workflow emails.

image

4. Configuration of the email template as identified in step 3 above. Basic>Setup>Email templates. FOr setting templates refer to the AX help file. Its a good source of information.

image

5.  Ensure that the batches to process the alerts and the email messages are active.

      a. Email batches - Administration>Periodic>Email processing> Batch.

image

     b. Alert batches - Basic>Periodic>Alerts

image

6. Workflow configuration is configured properly . There should one default configuration . Additional configurations may be maintained with specific conditions for becoming active.

image

e.g. workflow on purchase requisition may have following setup

image

One active version per configuration must be maintained.

image

7. Workflow rules should be defined properly. If the tasks are being assigned on hierarchy basis then there must be a stop condition maintained ( This is the general error that users do not maintained a stop condition.)

image

8. Setup events when to generate a notification in an approval process.

image

I think if above check list is cross checked during setup or troubleshooting most of the errors / problems would be solved related to workflow . For rest of the problems leave them for consultants/developers to investigate on case to case basis.