最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Using Document Management in Dynamics AX 2012

网络文摘 William 4730浏览 0评论

With document management in Dynamics AX 2012 it is possible to transfer data stored in Dynamics AX tables into documents of different types like Word, Excel or some other, different types.

You can use this feature if you have to export data from Dynamics AX into a document with standard text for which a SSRS-Report is not the best solution. An example could be information about a credit or debt which is not related to a specific invoice and is better send by a letter with standard text then by a collection letter related to an invoice.

So, let’s start by creating a new document type by using document type form (in: Organization administration -> Setup -> Document management -> Document types):

Document types setup

1. Create a new type and name it.
2. Choose the class (in this example a “Microsoft Word document”).
3. Set up the “Archive directory” (this is where the created documents are stored)
4. After this is done you have to create the Document table. In this case a Microsoft Word document table.

Press “Options” to associate the document template to a Dynamics AX table:

Association of Document template to Dynamics AX

Here you associate the Dynamics AX table on which the needed data primarily depend with the document template.

In Dynamics AX 2012 the underlying database is highly normalized, which means that most of the needed data is spread over many tables.
Unfortunately document management does not accommodate this fact: By default you just can link only one table to the specified (main) table.

Fortunately there is a solution for this problem: Just create a view which contains all the tables needed to receive all necessary data.

Two important information:
1. When creating the view the top table of the view should be the table you have specified in document management.
2. You have to setup an relation between the specified table and the just created view

Relations between maintable and view

By clicking the “field”-tab you can start associating the table/view-fields to document-bookmarks.

Press “CTRL” + “N” to create a new row. In the “Data Table” use the name of the view as data source. Note, that you cannot choose the views name from the list of tables. You have to type in the view’s name manually or you can use copy & paste.

In the “Data Field”-field choose a field from the view. In the “Bookmark”-field enter a name for the bookmark you will later use in the associated document.

Setting up bookmarks in document types

In this example I used the new “Computed Columns in Views”-feature of Dynamics AX 2012(as mentioned in a previous post) to do some calculations. The first calculates the difference in days between two dates. The second one calculates the discount which was deducted by the customer.

In Dynamics AX 2009 you had do this sort of calculations in the Word-document itself with the features provided by Word which were not so convenient than the new computed columns feature of Dynamics AX 2012.

If you have finished creating your Word-bookmarks to create these bookmarks in your Word template, too.

Creating Word template with bookmarks

In my example I have extracted the customers address (top left bookmarks), the customers ID (“Kd.-Nr.” is German and short version for customer ID), the paid amount and the Payment date from Dynamics AX.

As you can see I have named the Bookmark for payment date “TransDate” like the Bookmark in the document type form in Dynamics AX 2012.
After saving the work you can check if it works:

You have to go to a form which uses the primary table of the document type as its own primary table to receive data. I you go to a form which uses another primary table you can use this document type but it will receive no Dynamics AX data.

Document handling in a Dynamics AX-form

Select a dataset in Dynamics AX. Go inside the form to File -> Command -> Document Handling.

A new “Document Handling”-form opens. Choose “New” and the name of the document type you want to use.

Document handling in a Form

Dynamics AX 2012 needs a moment to extract the data. Word opens a new document based on the created template. (I am sorry, but I have no screenshot of a such a Word document filled with Dynamics AX data).

Restrictions of document types:
1. It is not a restriction of Dynamics AX document types itself, more a restriction of Word bookmarks: even you want to use a specific value multiple 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.

Possible sources of errors:
1. If an Word-document with just the text but without the Dynamics AX data opens, please check if you are in the right form (which uses the table as primary table as in your document type). Otherwise you will not receive any data from Dynamics AX 2012.
2. An other error which can occur is, if the Document Type has more bookmarks than the work-document which receives the data. Here you have to check that the number of bookmarks in Dynamics AX document type and in Word-Dokument. The number has to be exact the same.

转载请注明:ww12345678 的部落格 | AX Helper » Using Document Management in Dynamics AX 2012

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址