This article describes how to setup document type in Dynamics AX 2012 and how to transfer data stored in Dynamics AX tables into documents of different types like Word, Excel… You can use document type if you have to export data from an invoice, journal or other form into a document with standard text. To illustrate the setup, I will create a word document, linked to the free text invoice.
Access: Files > Tools > Options > General tab
- Go to the user option to allow the use of document handling: select “Document handling active”
- Select “Show attachment status” to highlight the “Attachment button when a document is attached to the record (invoice, journal, …)
Access: Organization administration > Setup > Document management > Document managment parameters
- In tab General: in the Archive directory field, enter the path to the archive directory.
- In tab Number sequences: select the number sequence code to use for naming your documents
2/ Create a new document type linked to a document template
Step 1: Create a word template
- Create a word document with the format: “Microsoft word template”
- In the place where you want variable datas, you need to insert a bookmark. The bookmarks will be linked to Dynamics AX. Example, I want to display the invoice number, or the invoice date, …
Step 2: Create a new document type
Access: Organization administration > Setup > Document management > Document types
- Create a new type and name it.
- Choose the class. In this example, I choose : “Microsoft Word document”.
- Set up the “Archive directory” (this is where the created documents are stored).
- In the remove field, you can choose between two options : remove document only or remove document and physical file.
- Click on “Option”
- On the Overview tab, in the column “Table”, select the table which the needed data primarily depend with the document template. In my example, I choose the table from the customer free text invoice.
- In the field “Template file”, select the word document template to use.
- Go to the “Field” tab
- In this form, select all the data you want to display in the word document.
- To create a new line : Ctrl + N
- To delete a line : Alt + F9
- For each line, enter in the column “Bookmark” the same name that you put in the template (word document).
- You need to have exactly the same number of bookmarks in the word document and in the dynamics AX setup.
- Remark : if you want to use a specific value several times, you have to create a new bookmark in Dynamics AX and in Word, because you can only use a Dynamics AX bookmark with one Word bookmark.
3/ Use a document type
Access: File > Command > Document handling
- Go to the the form which uses the primary table of the document type that you just created. In my example : All free text invoices form
- Select a line
- Click on the “Attachment” button or go to Files > Command > Document handling
- Click on “New” and select the document type.
- Dynamics AX creates a new document : one new line in the document handling form and a word document.
- You can add description in the document handling form if needed.
- When you go to the word document, you can see the datas from the free text invoice.
Remark : If you don’t know the name of the table. Go to the form (example free text invoice form). Select a record, make a right click and select “Personalize”. In this screen, you can find the name of the table.