Recent Posts

Pages: 1 2 [3] 4
AX BI and Reporting / Create a document library to store reports [AX 2012]
« Last post by smahdy on March 24, 2014, 01:08:19 AM »
Applies To: Microsoft Dynamics AX 2012 R2

If you are using Microsoft Dynamics AX 2012 R2, and if Microsoft SQL Server Reporting Services is running in SharePoint integrated mode, create a document library in SharePoint to store your reports. Complete this procedure before you deploy the default reports that are included with Microsoft Dynamics AX.


This procedure does not apply to you if you are running Reporting Services in native mode.

Create a document library

Create a document library on your SharePoint site to store reports. For information about how to create a document library, see the SharePoint documentation.

After you create the document library, add Reporting Services content types to the library. For more information, see Add Report Server Content Types to a Library (Reporting Services in SharePoint Integrated Mode) in the SQL Server documentation.

Specify the URL of the document library

After you have created the document library, complete the following procedure to specify the URL of the document library in the Report servers form in Microsoft Dynamics AX.

Open Microsoft Dynamics AX.

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

In the Configuration ID field, enter a name that identifies the Reporting Services instance and the Application Object Server (AOS) instance that you are connecting.

In the Description field, enter a brief description to help you identify the Reporting Services instance and the AOS instance that you are connecting.

Select the Default configuration check box to make the Reporting Services and AOS instances that are specified in this record the active connection.

On the Reporting Server information tab, enter the following information:

In the Server name field, enter the name of the server that is running Reporting Services.

In the Server instance name field, enter the name of the Reporting Services instance.


If you are using Reporting Services 2012, enter @Sharepoint.

Leave the Report Manager URL field blank. This field becomes unavailable when you select the SharePoint integrated mode check box in a later step.

In the Web service URL field, enter the URL of the Reporting Services web service.

If you are using Reporting Services 2008, the URL is typically http://[SSRSServerName]/ReportServer.

If you are using Reporting Services 2012, the URL is typically http://[SharePointServerName]/_vti_bin/ReportServer or http:[SharePointServerName]/sites/[SiteName]/_vti_bin/ReportServer.

Select the SharePoint integrated mode check box.

In the Microsoft Dynamics AX report folder field, enter the URL of the document library that you created to store reports.

For example, suppose that you have created a document library that is named Reports on a SharePoint site that is named Contoso. In this example, the URL is as follows:


On the Application Object Server information tab, select the name of the AOS instance.
AX BI and Reporting / Reporting Architecture - AX 2012
« Last post by smahdy on March 24, 2014, 01:06:46 AM »
The following diagram illustrates the architecture of the reporting functionality in Microsoft Dynamics AX.
Reporting architecture

1. A user requests a report.
Assume that a user clicks a menu item in the Microsoft Dynamics AX client. The menu item is bound to a SQL  Server Reporting Services report.
After the user clicks the menu item, a parameters form is displayed to the user. The user enters parameters to filter the data that will be displayed on the report.
The Microsoft Dynamics AX client then requests the report from Reporting Services. (The request includes the parameters entered by the user.)

2. Reporting Services receives the request and asks the Microsoft Dynamics AX server for the report data.
Reporting Services receives the request and examines the report on the server. The report is stored as an .rdl file. The .rdl file indicates the report’s data source. (The data source could be a Microsoft Dynamics AX query, a report data provider class, or an external data source via report data methods.)
In cases where a Microsoft Dynamics AX data source is used for the report, Reporting Services will use the Microsoft Dynamics AX data extension to retrieve the data.
At this point, Reporting Services asks Microsoft Dynamics AX for metadata about the data source. Reporting Services then requests the data for the report.

3. The Microsoft Dynamics AX server receives the request and sends the report data back to Reporting Services.
The Microsoft Dynamics AX services examine the query in the AOT to return the requested metadata. The services also execute the query to generate the data for the report.

Microsoft Dynamics AX returns the metadata and data to Reporting Services.

NOTE: Microsoft Dynamics AX enforces security on all data returned. If the user who is running the report is not allowed to see a specific field, the data for that field is not returned.

4. Reporting Services renders the report and sends it to the Microsoft Dynamics AX client.
The Microsoft Dynamics AX customization extension formats the report.
The customization extension uses metadata to provide automatic formatting of data and can affect the positioning and layout of elements in the report.
Reporting Services then renders the report into a visual representation and sends that to the Microsoft Dynamics AX client.

5. The report is displayed to the user.
The Microsoft Dynamics AX client displays the report to the user in the report viewer control.
General / How to: Grant User Access to a Report Server (Report Manager)
« Last post by smahdy on March 24, 2014, 01:05:06 AM »
Reporting Services uses role-based security to grant user access to a report server. On a new report server installation, only users who are members of the local Administrators group have permissions to report server content and operations. To make the report server available to other users, you must create role assignments that map  user or group accounts to a predefined role that specifies a collection of tasks.

For a report server that is configured for native mode, use Report Manager to assign users to a role. There are two types of roles:

Item-level roles are used to view, add, and manage report server content, subscriptions, report processing, and report history. Item-level role assignments are defined on the root node (the Home folder) or on specific folders or items farther down the hierarchy.
System-level roles grant access to site-wide operations that are not bound to any specific item. Examples include using Report Builder and using shared schedules.
The two types of roles complement each other and should be used together. For this reason, adding a user to a report server is a two-part operation. If you assign a user to an item-level role, you should also assign them to a system-level role. When assigning a user to a role, you must select a role that is already defined. To create, modify, or delete roles, use SQL Server Management Studio.

For a report server that is configured for SharePoint integrated mode, you configure access from a SharePoint site using SharePoint permissions. Permission levels on the SharePoint site determine access to report server content and operations. You must be a site administrator to grant permissions on a SharePoint site.

Before you start

Review the following list before adding users to a native mode report server.

You must be a member of the local Administrators group on the report server computer. If you are deploying Reporting Services on Windows Vista or Windows Server 2008, additional configuration is required before you can administer a report server locally.
To delegate this task to other users, create role assignments that map user accounts to Content Manager and System Administrator roles. Users who have Content Manager and System Administrator permissions can add users to a report server.
In SQL Server Management Studio, view the predefined roles for System Roles and User Roles so that you are familiar with the kinds of tasks in each role. Task descriptions are not visible in Report Manager, so you will want to be familiar with the roles before you begin adding users.
Optionally, customize the roles or define additional roles to include the collection of tasks that you require. For example, if you plan to use custom security settings for individual items, you might want to create a new role definition that grants view-access to folders.
To add a user or group to a system role

Start Report Manager.
Click Site Settings.
Click Security.
Click New Role Assignment.
In Group or user name, enter a Windows domain user or group account in this format: <domain>\<account>. If you are using forms authentication or custom security, specify the user or group account in the format that is correct for your deployment.
Select a system role, and then click OK.
Roles are cumulative, so if you select both System Administrator and System User, a user or group will be able to perform the tasks in both roles.

Repeat to create assignments for additional users or groups.
To add a user or group to an item role

Start Report Manager and locate the report item for which you want to add a user or group.
Hover over the item, and click the drop-down arrow.
In the drop-down menu, click Security.
Click New Role Assignment.
Note: If an item currently inherits security from a parent item, click Edit Item Security in the toolbar to change the security settings. Then click New Role Assignment.

In Group or user name, enter a Windows domain user or group account in this format: <domain>\<account>. If you are using forms authentication or custom security, specify the user or group account in the format that is correct for your deployment.
Select one or more role definitions that describe how the user or group should access the item, and then click OK.
Repeat to create assignments for additional users or groups.
AX Programming and Development / Top 10 issues discovered from Dynamics AX Health Check
« Last post by smahdy on March 24, 2014, 12:47:09 AM »
A very informative blog post by Bertrand Caillet covering important points for Dynamics AX best practices for health check, and it contains a sub links under main points. I am glade to share it over my page.
1. Max Degree of Parallelism is not set to 1
2. No Pre-Allocation for Non Continuous Number Sequences with high consumption
3. Insufficient Auto Growth for Data and Log files
4. Processor bottleneck for Dynamics AX batch processing
5. Heavy Application database logging
6. Missing Clustered indexes
7. Wrong Index maintenance
8. Enabled debug in Production
9. Power Management set to Balanced
10. Kernel and Application are outdated and should be patched
The Premier Field Engineer team has been running several hundred of Dynamics AX Health Check worldwide and I thought it would be interested to share the most common issues discovered during onsite. Some of the following issues might look trivial but the reality is that despite all the literature that exists today on the solution Dynamics AX, we can still see same repeated patterns, especially when default settings are used in production. Please note there is no logical order in this list.

1. Max Degree of Parallelism is not set to 1
The default setting from SQL Server installation is zero. If OLAP applications are running on the same SQL Server instance, the risk is that all CPUs are consumed (% Processor Time) and therefore impact performance of the OLTP application. To prevent this, we recommend to set MAXDOP to 1. Please note that in some situation when SQL Server batches or queries are run, using some degree of query parallelism can be beneficial. In this case setting Max degree of parallelism to 2 or 4 is probably a better value to take into account both types of queries.

2. No Pre-Allocation for Non Continuous Number Sequences with high consumption
This is a crucial setting in the Dynamics AX application that needs to be reviewed every few months on production to match the usage of the number sequences. Basically, number sequences can be Continuous or Non Continuous. When they are non-continuous, you can allow pre allocation per ID and therefore reduce the database calls and improve performance. When consumption is high, like several ID per seconds, we have noticed Lock Escalation events on the table NumberSequenceTable. This is especially true when Dynamics AX batch are running and generate thousands of records for Journals Lines creation or Sales Order Invoicing. Please read this blog post to better estimate this consumption.

3. Insufficient Auto Growth for Data and Log files
The default Auto growth is By 1 MB for Data and By 10% for Log files. If the initial size is too small, you will notice frequent auto growth events, resulting in negative performance impact. In the SQL trace, you can monitor such event with ID and see the duration of each auto growth event. The goal is to set an appropriate Auto Growth value on the Dynamics AX and TempDB Data and Log files to prevent frequent auto growth events during daytime. You can monitor such events and their duration in milliseconds in the SQL Trace with ID 92 and 93. One recommendation is to set the Auto Growth with a greater value, from 200MB to 500MB.

4. Processor bottleneck for Dynamics AX batch processing
Most of the customer running Dynamics AX are enabling only one AOS instance for the batch processing and several AOS dedicated for rich clients load which therefore limit the number of batch thread to the number of logical processor available on that single AOS instance. Also the setting on the AOS batch is often the default one with 8 maximum batch thread and 24 hours a day schedule . A good ratio to calculate the number of thread is to multiply the number of cores by 2, but this depends on the processes running and should be validated in testing. To overcome this limitation, you can set different batch thread for different time of the day and enable more AOS for Batch processing at night. For example, you can dedicate one AOS for Rich client load from 8 am to 6 pm and leverage it for batch processing at night. You can read this blog post to learn how to tune the number of thread required for faster batch execution.

5. Heavy Application database logging
This is another important setting in the Dynamics AX application that often has negative impact when over utilized. This feature allows to track all CRUD operations (including Rename primary key) on any field and any table of the database. This information will be stored in the table SYSDATABASELOG. You should not use this feature to track automated transactions run in batch jobs. You can monitor the table growth of SYSDATABASELOG and estimate the most expensive table set up with database logging. Please also notice that enabling the logging on field like CreatedDateTime or ModifiedDateTime will change the default behaviour of InsertRecordSet from a single round trip to the database to a record-by-record operation. The three recommendations are:
Define a retention policy to only keep the latest 3 months for example so that size of table SYSDATABASELOG remains small. You can find the clean-up form under Administration | Inquiries | Database log | Clean up log.
Avoid heavy logging for transactional tables processed during the batch and prioritize activity that is absolutely necessary either for legal compliance or to meet other business requirements.
Avoid logging the columns CreatedDateTime or ModifiedDateTime of any table.

6. Missing Clustered indexes
This might not be the most common issues but it is definitively one of the most impacting one. All tables in an OLTP database should have clustered indexes, and you should investigate them by looking at the highly active tables, tables frequently involved in blocking or deadlock situations, tables that frequently incur the overhead of forwarded rows. Because the database model is changing during the lifecycle of the application with new customization and because indexes are managed from the Application Object Tree, it is important to periodically check the missing indexes from SQL Server Statistics. You can use the query “4-Analyze_SQL_Indexes.sql” from Dynamicsperf version 1.1.6 to find all missing indexes.

7. Wrong Index maintenance
Following the Missing clustered indexes issue mentioned above, the index maintenance is clearly one of the unhealthiest issue for Dynamics AX. Having a bad index maintenance or no index maintenance at all will have the same consequences: when statistics are outdated, Query Plan will use SCAN instead of SEEK operations and their performance will be badly impacted. The level of fragmentation is not that critical as such for performance, but it should be part of the weekly maintenance. The following is a recommended example:
Reorganize indexes that are larger than 1000 pages and are between 10% and 30% fragmented.
Rebuild indexes that are larger than 1000 pages and more than 30% fragmented using a fill factor between 85% and 95% depending on the frequency of the job execution.
It is also strongly recommended to run Update Statistics regularly with FULL SCAN, or with at least a 50% sample, as well as having Auto_Create_Stats and Auto_Update_Stats enabled. If you are running SQL 2008 R2 SP1 or greater, you can also enable Trace Flag 2371.

8. Enabled debug in Production
In the Dynamics AX Server Configuration Utility, you should always disable the two settings that allow user breakpoint and global breakpoint to debug X++ code. Even though you delete all breakpoints in the Application Object Tree, you will still suffer from a clear performance degradation around 10%.

9. Power Management set to Balanced
This is an easy one but almost never implemented in production since the default power management is set to balance. Changing it to High performance is highly recommended for all Windows Server 2008 used in Production. You can see this setting from Control Panel – hardware – Power Options or with the following command: “powercfg –getactivescheme”.

10. Kernel and Application are outdated and should be patched
Last but not least, maintain your Dynamics AX solution as much updated as possible. For example, you can notice that latest Rollup for Dynamics AX 2009 SP1 is RU8 and is already one year old. Several hundred of Hot Fixes have been released since and it is a best practice to apply those to leverage the latest fixes from the Product Group. The two recommendations are:
Patch the Binaries with the latest Kernel available. You can see the latest KB on the AX Support Blog. As of today, the latest one for Dynamics AX 2009 SP1 is build 5.0.1600.1824 from June 2013.
For the Application, you should upgrade to latest RU available, but you can also proactively check the list of individual Hot Fixes relevant to your business logic.
As you can see this list is not exhaustive and we could elaborate hundred of issues discovered from existing Dynamics AX live instance, but I do hope it can help you remediate some of the current issues you may experience. I will also encourage you to read the great article written by Arvind Shyamsundar on MSPFE blog regarding the 10 top SQL Server Issues uncovered by the SQL Server Risk Assessment Program.
Finally, please contact your Microsoft Premier Technical Account Manager if you will like to receive guidance from the Premier Field Engineering.

Source: Dynamics AX in the Filed
AX Programming and Development / Temporary Tables In Dynamics AX
« Last post by smahdy on March 24, 2014, 12:32:59 AM »
In Microsoft Dynamics AX, a table typically maps to a corresponding table in the database. Temporary tables enable to you define table objects that are not persisted to the database. Define a table as a temporary table by doing one of the following:

Set the table's Temporary property to Yes at design time.


Call the setTmp method in X++ code.

A temporary table is held in memory until its size reaches 128 KB. The dataset is then written to a disk file. The disk file for a temporary table has the naming convention $tmp<nnnnnnnn>.$$$.

A temporary table is located in the Application Object Tree (AOT) under the Data DictionaryTables node, just like a persisted table. If a table is defined as temporary, you can use it just as you would a static table. All X++ DML statements can be run against a temporary table.

Note: It is a best practice to infix temporary table names with Tmp. This improves readability in code.

Scope      A temporary table exists only while a record buffer variable that references the table exists. No memory is allocated to the temporary table until the first record is inserted. At that point, memory is allocated. Disk space is allocated, if it is needed. As soon as the record buffer goes out of scope, the memory is de-allocated and the disk file is deleted.

A temporary table resides on the tier where the first record is inserted. If a record is inserted on the server tier, memory for the temporary table is allocated on the server tier. If the temporary table exceeds 128 KB, a disk file is created on the server.

Adding data to temp table

To add data to a temporary table, you must define the record buffer and call the insert method. The following is a code example that uses the TmpCustLedger table.

static void TableTmpInsertRecord(Args _args)
TmpCustLedger custTmpLedger;
custTmpLedger.AccountNum = '1000';
custTmpLedger.Name = 'NameValue';
custTmpLedger.Balance01 = 2345000;

To free the memory and delete the file for the temporary table, set the record buffer variable to null, as follows.

custTmpLedger = null;

To populate a temporary table with data from a persisted table, use the setTmp method. The following code example copies all customers in Toronto to the temporary table.

static void CopyPersistedTableToTemp(Args _args)
    CustTable custTable;
    CustTable custTmpLedger;
while select custTable where custTable.City == 'Toronto'


Indexes can be defined on a temporary table just as you would a persisted table. If a temporary table is created by copying a persisted table, the indexes are also copied to the temporary table. Indexes are very useful for retrieving data in temporary tables especially if the temporary table data is in a disk file.

Temporary table vs. Container

Microsoft Dynamics AX supports a special data type called a container. This data type can be used just as you would use a temporary table.

Data in containers are stored and retrieved sequentially, but a temporary table enables you to define indexes to speed up data retrieval.
Containers provide slower data access if you are working with many records. However, if you are working with only a few records, use a container.
Another important difference between temporary tables and containers is how they are used in method calls. When you pass a temporary table into a method call, it is passed by reference. Containers are passed by value. When a variable is passed by reference, only a pointer to the object is passed into the method. When a variable is passed by value, a new copy of the variable is passed into the method. If the computer has a limited amount of memory, it might start swapping memory to disk, slowing down application execution. When you pass a variable into a method, a temporary table may provide better performance than a container.
AX Programming and Development / Create and execute a batch job AX 2012
« Last post by smahdy on March 24, 2014, 12:31:47 AM »
Microsoft Dynamics AX 2012 includes numerous batch jobs that perform operations such as generating reports, creating sales invoices, and processing journals. However, in several situations, organizations need to create their own batch jobs. The batch framework provides full flexibility in the types of jobs that you can create. This section walks you through the following steps, which are required for creating, executing, and managing a batch job:
1. Create a batch-executable class.
2. Create a batch job and define the execution schedule.
3. Configure a batch server and create a batch group. (It be will explained in another post)
4. Manage the batch job. (It will be explained in another post)
Create a batch-executable class
The first step in developing a batch job is to define a class that can be executed as a batch task. Many classes included with Microsoft Dynamics AX 2012 are already enabled for batch processing. You can also design a batch-executable class, as shown in the following example:
public class ExampleBatchTask extends RunBaseBatch
To run as a batch task, a class must implement the Batchable interface. The best way to implement the interface contract is to extend the RunBaseBatch abstract class, which provides much of the necessary
infrastructure for creating a batch-executable class. An alternative is to use the SysOperation framework, which provides additional advantages compared to extending the RunBaseBatch class. Will post more information about the SysOperation framework Later.
Table below describes the methods that must be implemented when you extend the RunBaseBatch class. The following sections describe these methods in more detail.

Method Description
run Contains the core logic for your batch task
pack Serializes the list of variables used in the class
unpack Deserializes the list of variables used in the class
canGoBatchJournal Determines whether the class appears in the Batch Task form
run methodYou implement the core logic of your batch class in the run method. The run method is called by the batch framework for executing the task defined within it. You can run most of the X++ code in this method; however, there are some limitations on the operations that you can implement. For example, you can’t call any client logic or dialog boxes. However, you can still use the Infolog class. All Infolog and exception messages are captured when the batch class executes, and they are stored in the batch table. You can view these later in the Batch Job form or the Batch Job History form, both of which are located under System Administration > Inquiries > Batch Jobs.

Note If an error message is written to the Infolog, it does not mean that the task has failed; instead, an exception must be thrown to indicate the failure
pack and unpack methods
A class that extends RunBaseBatch must also implement the pack and unpack methods to enable the class to be serialized. When a batch task is created, its member variables are serialized by using the pack method and stored in the batch table. Later, when the batch server picks up the task for execution, it deserializes class member variables by using the unpack method. So it’s important to provide a correct list of the  variables that are necessary for class execution. If any member variable isn’t packable, then the class can’t be serialized and deserialized to the same state.
The following example shows the implementation of the pack and unpack methods:
public container pack()
                        return [#CurrentVersion,#CurrentList];
public boolean unpack(container _packedClass)
                        Version version = RunBase::getVersion(_packedClass);
                        switch (version)
                                  case #CurrentVersion:
                                                        [version,#CurrentList] = _packedClass;
                                                        return false;
                    return true;

The #CurrentList and #CurrentVersion macros that are referenced in the preceding code must be defined in the class declaration. Using a macro simplifies the management of variables in the class. If you add or remove variables later, you can manage the list by modifying the macro. The #CurrentList macro holds a list of the class member variables to pack, as shown here:
canGoBatchJournal method
When a system administrator creates a new batch task by using the Batch Task form, the canGoBatchJournal method determines whether the batch task class appears in the list of available classes. For an example of how to use canGoBatchJournal.

Create a batch jobThe second step in developing a batch job is to create the batch job and add batch tasks. You can create a batch job in three ways:
■ By using the dialog box of a batch-enabled class
■ By using the Batch Job Designer form
■ By using the Batch API (It be will explained in another post)
The method you use depends on the degree of flexibility that you need and the complexity of the batch job. To create a simple batch job, consisting of a single task with no dependencies, you typically use the dialog box of a batch-executable class; to create a more complex batch job, consisting of several tasks that might have dependencies, use the Batch Job form; to create a highly complex or very large batch job, or one that needs to be integrated with other business logic, use the Batch API.
The following sections provide an example of using each method.
Create a batch job from the dialog box of a batch-executable class
The simplest way to run a batch-executable class as a batch job is to invoke the class by using a menu item. A menu item that points to a batch-executable class automatically opens a dialog box that lets
the user create a batch job. On the Batch tab of the dialog box, select the Batch Processing check box, as shown for the Change based alerts class in Figure below. When you select Batch Processing and click
OK, a new batch job with the task that represents the batch-executable class is created. The batch job then runs asynchronously at the date and time you specify. You can also set up recurrences or alerts
for the job by clicking the appropriate button on the right side of the dialog box. You can also specify the batch group for the task by using the drop-down list.

Create a batch job by using the Batch Job formYou can open the Batch Job form from several places. For example, you can open it by clicking Batch Jobs from System Administration > Inquiries > Batch Jobs or by selecting My Batch Jobs (for users) from Home > Inquiries > My Batch Jobs. Both menu items open the same form, but the information that is presented in the form differs, depending on the menu item that you use to open it. Depending on how you open the form and your level of access, you can view either the batch jobs that you have created or all batch jobs that are scheduled in the system.
Press Ctrl+N to create a new batch job, and then enter the details for the job in the grid or on the General tab: a description, and the date and time at which you want the job to start. You can also set up recurrence for the batch job by clicking Recurrence on the menu bar, and then entering a range and pattern for the recurrence.
Note If you don’t enter a date and time, the current date and time are entered automatically.
figure below show Batch Job Form
Batch tasks form
To create a task, do the following:
1. Press Ctrl+N to create the task.
2. In Task Description, enter a description of the task.
3. In Company Accounts, select the company in which the task runs.
4. In Class Name, select the process that you want the task to run. Classes appear in a lookup list containing all available batch-enabled classes. The lookup list appears only if the CanGoBatchJournal property is enabled.
5. In Batch Group, select a batch group for the task if necessary.
6. Save the task by pressing Ctrl+S.
7. Specify class parameters if necessary. As mentioned in previous sections, each batch task represents
a batch-executable class. Sometimes you need to set up parameters for that class.
For example, you might need to specify posting parameters for invoice posting. To do that, click Parameters on the menu bar in the Batch Tasks form. A dialog box specific to the selected class is displayed.
Note If you are creating a custom batch class, you must design the parameters form manually. If you implement a batch based on the SysOperation framework, this process is highly simplified. After you specify the necessary parameters and click OK, the class parameters are packed and saved in the Batch table and then are restored when the class executes.
8. Set up dependencies or advanced sequencing between tasks, if necessary.

After you create the batch job and add tasks to it, you can use the Batch Tasks form to define dependencies between the tasks. If no dependencies or conditions are defined within a job, the batch server automatically executes the tasks in parallel. (To configure the maximum number of parallel tasks, use the Maximum Batch Threads parameter in the Server Configuration form.)
If you need to use advanced sequencing to accommodate your business process flow, you can use either the Batch Tasks form or the Batch API. You can use these tools to construct complex dependency
trees that let you schedule batch jobs tasks in parallel, add multiple dependencies between batch tasks, choose different execution paths based on the results of the previous batch task, and so on.
For example, suppose that the job, JOB1, has seven tasks: TASK1, TASK2, TASK3, TASK4, TASK5, TASK6, and TASK7, and you want to set up the following sequence and dependencies for it:
■ TASK1 runs first.
■ TASK2 runs on completion (Ended or Error) of TASK1 (regardless of the success or failure of TASK1).
■ TASK3 runs on success (Ended) of TASK2.
■ TASK4 runs on success (Ended) of TASK2.
■ TASK5 runs on failure (Error) of TASK2.
■ TASK6 runs on failure (Error) of TASK3.
■ TASK7 runs on success (Ended) of both TASK3 and TASK4.
dependency tree for JOB
To define these task dependencies and to tell the system how to handle them, select a child task—for example, TASK2—from the preceding list, and then do the following:
1. In the Batch Tasks form, click in the Has Conditions grid, and then press Ctrl+N to create a new condition.
2. Select the task ID of the parent task, such as TASK1.
3. Select the status that the parent task must reach before the dependent task can run. For example, TASK2 starts when the status of TASK1 becomes Ended or Error.
4. Press Ctrl+S to save the condition.
5. If you enter more than one condition, and if all conditions must be met before the dependent task can run, select a condition type of All.
Alternatively, if the dependent task can run after any of the conditions are met, select a condition type of Any.
You can use the Batch Tasks form to define how the system handles task failures. To ignore the failure of a specific task, select Ignore Task Failure for that task on the General tab. If you select this option, the failure of the task doesn’t cause the job to fail. You can also use Maximum Retries to specify the number of times a task should be retried before it fails.
Imparted from Inside Dynamics AX 2012 Book.
AX Programming and Development / Call Form By Code using X++
« Last post by smahdy on March 24, 2014, 12:26:20 AM »
Let’s call Ledger budget form from inside X++ job by pass ledgerTable record as argument and apply filter by budget model

static void CallLedgerBudgetForm(Args _args)
LedgerTable                            ledgerTable;
BudgetModelId                          modelId;
Args                                    args;
FormRun                                formRun;
FormDataSource                          fds;
QueryBuildDataSource                    qbds;
QueryBuildRange                        qbr;

select LedgerTable where LedgerTable.AccountNum == '110110' ;
ModelId= 'SUb1';

args = new Args(formstr("LedgerBudget"));
formRun = classfactory.formRunClass(args);
fds = formRun.dataSource();
qbds = fds.query().dataSourceTable(tablenum(LedgerBudget));
qbr = qbds.addRange(fieldnum(LedgerBudget,ModelNum));

AX Programming and Development / How to remove the duplicate objects in AOT Using X++
« Last post by smahdy on March 24, 2014, 12:24:40 AM »
Scenario : Nags came across a requirement for duplicating the production instance.He followed the following steps
1. Setup a new instance and Copied the var.aod files from production instance and restored the DB with production DB.
2. After that he kept the application for compilation. When the compilation ends , he tries to synchronize the Data dictionary. But he was getting error during synchronization because some objects were duplicated in layers. e.g System will show two ItemId fields at table level.
Use the following code to delete the identical copy.
static void FindAndDeleteIdenticalObjects(Args _args)
    SysTreeNode comparable1, comparable2;
    TreeNode curLevelTreeNode, upperLevelTreeNode;
    UtilIdElements utilElements, joinUtilElements;
    while select UtilElements
    where UtilElements.utilLevel == UtilEntryLevel::var &&
        UtilElements.recordType == UtilElementType::Form ||
        Utilelements.recordType == UtilElementType::Report ||
        Utilelements.recordType == UtilElementType::Table ||
        Utilelements.recordType == UtilElementType::Class ||
        Utilelements.recordType == UtilElementType::Enum ||
        Utilelements.recordType == UtilElementType::ExtendedType
        //Should use join if for a normal table, but not applicable for UtilElements
        //Performance hit if use exists join
        select firstonly recid from joinUtilElements
        where joinUtilElements.utilLevel != UtilElements.utilLevel && == &&
        joinUtilElements.recordType == UtilElements.recordType;
        if (joinUtilElements.RecId)
            //Thanks for Jim Shepherd here
            curLevelTreeNode = SysTreeNode::findNodeInLayer(UtilElements.recordType,, UtilElements.parentId, UtilElements.utilLevel);
            upperLevelTreeNode = SysTreeNode::getLayeredNode(curLevelTreenode, 1);
            comparable1 = SysTreeNode::newTreeNode(curLevelTreeNode);
            comparable2 = SysTreeNode::newTreeNode(upperLevelTreeNode);
            if (SysCompare::silentCompare(comparable1, comparable2))
                info(strFmt("Element name: %1, Element type: %2",, enum2str(UtilElements.recordType)));
                //Remove the node
AX Programming and Development / Exporting data to Excel by Code x++
« Last post by smahdy on March 24, 2014, 12:22:51 AM »
Below is sample code how to export data to Excel File by code x++
static void DASCreateExcelDocument(Args _args)
  SynonecelApplication  xlsApplication;
  SynonecelWorkBooks    xlsWorkBookCollection;
  SynonecelWorkBook    xlsWorkBook;
  SynonecelWorkSheets  xlsWorkSheetCollection;
  SynonecelWorkSheet    xlsWorkSheet;
  SynonecelRange        xlasRange;
  CustTable            custTable;
  int                  row = 1;
  str                  fileName;
  fileName = "C:\Test.xlsx";
  //Initialize Excel instance
  xlsApplication          = SynonecelApplication::construct();
  //Open Excel document
  //Create Excel WorkBook and WorkSheet
  xlsWorkBookCollection    = xlsApplication.workbooks();
  xlsWorkBook              = xlsWorkBookCollection.add();
  xlsWorkSheetCollection  = xlsWorkBook.worksheets();
  xlsWorkSheet            = xlsWorkSheetCollection.itemFromNum(1);
  //Excel columns captions
  xlsWorkSheet.cells().item(row,1).value("Account Num");
  //Fill Excel with CustTable AccountNum and Name fields (only 10 records)
  while select custTable
      if(row == 10)
  //Check whether the document already exists
  //Save Excel document
  //Open Excel document
  //Close Excel
AX Administration / Security Roles - Ax 2012
« Last post by smahdy on March 23, 2014, 07:36:24 PM »
All users must be assigned to at least one security role in order to have access to Microsoft Dynamics AX. The security roles that are assigned to a user determine the duties that the user can perform and the parts of the user interface that the user can view.

Administrators can apply data security policies to limit the data that the users in a role have access to. For example, a user in a role may have access to data only from a single organization. The administrator can also specify the level of access that the users in a role have to current, past, and future records. For example, users in a role can be assigned privileges that allow them to view records for all periods, but that allow them to modify records only for the current period.

By managing access through security roles, administrators save time because they do not have to manage access separately for each user. Security roles are defined one time for all organizations. In addition, users can be automatically assigned to roles based on business data. For example, the administrator can set up a rule that associates a Human resources position with a security role. Any time that users are assigned to that position, those users are automatically added to the appropriate security roles. Users can also be automatically added to or removed from roles based on the Active Directory groups that they belong to.

Security roles can be organized into a hierarchy. A role hierarchy enables roles to be defined as combinations of other roles. For example, the sales manager role can be defined as a combination of the manager role and the salesperson role.

In the security model for Microsoft Dynamics AX, duties and privileges are used to grant access to the program. For example, the sales manager role can be assigned the Maintain revenue policies and Review sales orders duties.
By default, sample security roles are provided. All functionality in Microsoft Dynamics AX is associated with at least one of the sample security roles. The administrator can assign users to the sample security roles, modify the sample security roles to fit the needs of the business, or create new security roles. By default, the sample roles are not arranged in a hierarchy.

NOTE: The sample security roles do not correspond to Role Centers.
Pages: 1 2 [3] 4