Dynamics AX : Document handling

The following solution is to use the document handling feature of AX and generate a word document by populating data into a word template. Following is the detail on how to do it .

When we create a new word document through document handling , we can transfer data from tables in Microsoft Dynamics AX to bookmarks in the new document. This is done by creating a template with some standard text and some bookmarks where the data from tables are to be inserted. For example we can transfer the address and contact information for a customer to the letter head in a Microsoft Word document when creating a new letter for that customer.

Prepare a Word template :We need to create a Word template with bookmarks where the data should be inserted. Then we set up the document type by linking the document type to the template and by adding the data fields to be transferred to the individual bookmarks.

Step A : Create a new Word template

1.            From the Start menu, click All Programs > Microsoft Office > Microsoft Office Word.

2.            In the new template, add the text and graphics we want to appear in all new documents that we base on the template.

3.            Place the cursor where we want to insert data from Microsoft Dynamics AX and then click Insert > Bookmark.

4.            Type a meaningful name for the bookmark and click Add.

5.            Repeat step 3 through 4 for each bookmark that we want in the template.

6.            On the File menu, click Save As.

7.            In File name, type a name for the new template.

8.            In Save as type, click Document Template, and then click Save.

 

Note : It is important to use a table where more than one row of data is needed. e.g. if we are expecting to insert more than one invoices for a vendor as shown in the above screen shot. This will help maintain the format when the data is populated by the system. Otherwise the data will be distorted.

Step B : Link the template to a document type

1.            Click Basic > Setup > Document management > Document types.

2.            Select the document type that we want to link to a template.

3.            Click Options.

4.            In the Table list, select the table to associate with the template.

5.            In the Template file list, type the path to the template file or use the browse button to locate the file on the computer or network.

Class description:             Create Word document via COM

Group:                                  Document          

Step C : Add bookmark information to table fields

1.            Click the button “Option”.. In the Options form, On overview tab give the name of the table and path of the template file

    select the table that is linked to the template that we want to use.

2.            Select the Fields tab.

3.            Press CTRL+N to add a field to be transferred.

4.            In the Data table list, select a table to get data from.

5.            In the Data field list, select the data field to get data from.

6.            In Bookmark, type the name of the bookmark we have inserted in the document where the data will be inserted.

7.            Select Hard return to insert a line break after the data inserted (optional).

8.            Repeat step 3 through 7 to add more data fields to the list.

Note : The table we get the data from does not have to match the table selected on the Overview tab, but the two tables have to be related.

                The Document handling feature can only create one letter per invoice.

On Field tab select the AX table and fields as shown below in the screen shot . For each field give the Bookmark from the template.

 

Step D : Test the report

Go to vendor master and select a vendor whose invoices have been  pending / on hold.

Click document handling button. Indocument handling click the Button New and select the document type created in previous Step B.

A word document will be created with data for the vendor

Verify the data on the document. Pls note that the invoice number date and amount fields are nicely aligned . If the bookmarks had not been in a table in the template then the invoice details would have been distorted. ( try using  a template with bookmarks without table and see yourself )

 

I hope the above will be of help to many AX consultants in avoiding a few report customisations.

This entry was posted in Dynamics AX, AX2009. Bookmark the permalink.

12 Responses to Dynamics AX : Document handling

  1. Brad says:

    We are using document handling to generatea word document that we can edit and include more detailed information on our quotes. We have a table in the document and bookmarks to insert the quotation line data to and this work EXCEPT that it puts ALL records in a single row in the Word table. Is there anyway to change this to insert each quotation line record into a new row of the Word table?I have tried using the had return option but it does not work as it sends a CRLF instead of a TAB key which would make the table create a new line (if at the bottom of the table.I can email an example if you wish.

  2. Shekhar says:

    Hi Brad,The creating a document through document handling using COM is not very polished functionality that can support your requirement . The following a. We can customize AX and can provide you with a specific feature which will generate a quotation in the template as per your need. If you have a budget for this then let me know.b. Try using ATLAS XL, an add-on for Microsoft Dynamics AX, to pull data in the template you have .

  3. Pingback: Document Handling in Ax 2009 « Ansar Basha

  4. George says:

    Is there some way we can see that a Document is attached to some records and not others ? Would be very helpful!

    • You will need to customise it .. I think there is a something already done at the quotation level in Std AX to show an image in the overview grid if there is a document attached with the record.

      • George says:

        Incredible that this was handled brilliantly in early versions, with less and less visibility in subsequent versions!

    • RV says:

      Check DAX Option setting, tab General, Document handling group…for further information check Help for this section (F1)

      • George Burrell says:

        I did what you said RV, found the “Show attachment status” flag – and now when I have a document attached to a record, I see the attachment Icon bottom left of my form is illuminated. Thank you for your illumination!

    • joanna06 says:

      Seeing if a document is attached would be great, but where and how do you see it? How do you customize it? I can’t seem to find it in the Setup fields.

  5. renevolkmerene says:

    Thanks for this post, very helpful.
    Regards RV

  6. Muhammad Annus says:

    how we generate multiple word template using document handling.

  7. Hicks says:

    Thanks for the post.
    May I ask you, that is there any way to insert an image from ax into the word template?
    And the other question: can I do that, make only one template and assign it to all of the companies?

Leave a comment