Aug 27, 2012

How to count the number of records in a report in ax 2009.

Sometimes we need to calculate the percentages in the report basing on the number of records which are displaying in the report. To achieve that first we need to calculate the number of records in report.
By using  SysQuery::countLoops() method we can calculate the number of records.

Actually i used many tables in this particular report but the main table in SalesTable. i am building the dynamics query and joining all rest of the tables into this table. so my main table in this report is SalesTable and my query name is queryRun_1. I used this query in the fetch method.
the code should be as shown below.

  while(queryRun_1.next())
         {
            SalesTable = queryRun_1.get(tablenum(salesTable));


             this.send(SalesTable);


           NOR =  SysQuery::countLoops(queryRun_1);

         }

countLoops is the method which is used to count the number of loops while query is executing from the class SysQuery.
And NOR is just a variable to count the number of records which is declared in class declaration so that we can used it anywhere in our report.

Aug 25, 2012

Security Keys in Ax


Security Keys in Ax

Dynamics Ax provides following keys to provide the security for application

1. License Keys:
First Level Security, specifies what all features/modules/development tools we can access in the standard product. License Keys will be used after installation to unlock the product. License Keys will be issued by the Microsoft for partners/vendors to develop vertical/generic solutions.

2. Configuration Keys:
Second Level Security, To Enable/Disable the object/feature for all the users.

3. Security Keys:
If you want to enable/disable object/features to group of users.

4. Record Level security:
Basically it deals with the data, if you want to restrict the viewing of records per user group than we setup record level security.

Title fields in form by using X++ code

Today i would like to share how to get the title fields on the form with X++ code.

For that first i created a form with the name TestTitleFields.
And i selected SalesTable to do my coding from this table i am going to display the title fields on my newly created form.
select the SalesTable methods node and right click and click on new method. and write the following code in code editor window.


Display str getName()
{
    return ' Chowdary';
}

after that select the methods node and right click and click on override method and choose caption method.write the following code in the code editor.


public str caption()
{
    str ret;

    ret = super()+' Venkatesh'+this.getName();

    return ret;
}

After that you SalesTable table will be as shown below.




And go to your form and expand design and select design go to properties and set the propperty TitleDataSource to SalesTable.after that your form will be as shown below.


Now open your form you will see the title field as shown in the below screen.

It will not override the already existing values in the table level title fields. if you want to override those values simply remove the super from the caption method.