Home > Ax Technical > HTML based Report in Dynamics Ax

HTML based Report in Dynamics Ax

February 20, 2007 Leave a comment Go to comments
          Though Ax reports offer lot of inbuilt functionality, it happens so that we need some features like tables with different alignment styles. Dynamics Ax has the solution for cases of that kind  too…
 
The solutions is very simple and easier, it is using HTML pages for reporting.
 
check out the step by step methods to create a HTML based report.
1. Decide the type of report you want, now try to simulate the report layout using some HTML editor
   or using someonline editors too.
   I used an online editor from w3schools(Check out here
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_span)
   Just let the layout be as it is, now let us turn our attention to Ax and later use the HTML code generated for the layout.
 
2. Create a query in the AOT if you want to use it in your report
 
3. Create a simple class that extends runbase and add all necessary runbase methods
 
4. Add any dialog fields which you require for your report
 
5. Now add a method called GenerateHTML to your runbase class, you can refer to the following class for example   
    Classes ->HRMSkillGapEmployeeHTMLGenerate
   with a signature of this sort

   CCHTMLString generateHTML()
   {
   }

6. Inside this method use the queryrun class to fetch the records in loop

 

7. Now move the HTML code that was generated earlier to this method and convert all static content to dynamic(i.e)by
    placing the value fetched through the query  
    eg: generated code :
                                        <tr> <th bgcolor="lightblue">CustomerName</th>’ 
                                 <td><b>The Light Company </b></td>’ 
                                 </tr>
          Dynamic code  :

                                 <tr> <th bgcolor="lightblue">CustomerName</th>’ 
                                 <td><b>CustTable.Name </b></td>’ 
                                 </tr>
 

8. Now create a method with anyname that you want say runreport(), Place the follwoing code
    in to it.
 
    Args    args;
    Object  object;
    FormRun formRun;
    ;
    args = new Args();
    args.name(formstr(CCHTMLPrintPreview));
    args.caller(this);
    args.record();
    formRun = classfactory.formRunClass(args);
    object = formRun;
    object.parmObject(this);
    object.parmHTMLObject(this);
    object.init();
    object.run();
    object.wait();
 
  The form CCHTMLPrintPreview is responsible for displaying your HTMLcode in the form of Axreport. We invoke this form   through the following code.This form uses GenerateHTML method that we created earlier to get the data to be displayed
 
9. Create a run method and call the above created method(runreport()) to activate the form
 
10.Create a main method for it, calling the prompt and run method of our class.
 
11.Drag the class to Output MenuItem and Place the menuItem in to any module that you want, execute it to see the 
    report.
 
   You can also further refer to the follwoing report for further information and other ways of fetching and feeding data for report rendering.
 
I have created a simple class that will help you in understanding this, download and check out.
 
 
Snap Shot of my output
 
      
 
………………..The "WoW" effect
 
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: