Today I will try to show you one new cool feature of NAV 5.0 for
end-users. NAV 5.0 is able to export any form into XML and using XSLT
(template, stylesheet, transformation - you can name it in different
ways) can be this XML transformed into another XML. And because MS Word
and MS Excel is able to open documents defined in XML, you can create
Word and Excel documents in this way (and for any other application).
How it is working
On the toolbar there are three new shortcuts, which can be used in
any time when you have some form opened (Last three shortcuts on the
picture, behind the watermark).

For example, when you open the G/L Account card, and you click on
the first shortcut (Word), you will get the Word document with all data
accessible on the G/L Account card.


In this Word document, there are all tabs from the form and all
controls from these tabs. If you use the second shortcut (Excel), you
will get slightly different result:

Each tab has own Sheet, but there are same data like in the MS Word.
In both applications you can open the original NAV form through
clicking on the title in exported document. It means that this document
is still "linked" with the original and you don't need to search in NAV
for the original form and record.
This was example of using defualt template, which is usable for all
forms. But you can attach new templates for specific NAV form and than
the user can select this template for exporting within template
selection form (third shortcut). In the demo DB there are templates for
Customer letter (on Customer card), Contact letter (on Contact card),
Vendor letter (on Vendor card) and Sales Quote (on Sales quote card)
and Sales Order Confirmation (on Sales order card).


You can see that the result can include additional data that are not
part of the form in NAV (e.g. Company name, Payment terms description
etc.). It means that the result can be complex and you do not need to
include all data on the form just because you need to export it.
What is behind
From designer point of view is this feature very
complex. Developer needs to understand XML, XSLT and target application
XML. If you want to customize this feature, you have two possibilities.
You can change the functions in CU1 which are used for this export (you
can change how it transforms the data, which template is selected
etc.), or you can modify or create own XSLT template (you can change
the result of the transformation).
In the functions, when exporting some form, the XML
with description of this form is passed into function which will apply
the transformation from selected XSLT template, and the result is sent
into the application itself. On the screenshot of the Data XML (the XML
describing the form) you can see that all controls are included with
some informations. From position or size is there just the width of the
control (if you change width of column on the form, the excel column in
exported document will have similar width)
.
In
the example there are data from Sales order card form. There is header
tab control, line subform, Info panel frame etc. This XML file than can
be transformed through XSLT file. Result of this transformation can
look like this:

On the screenshot is part of the Sales quote XSLT used to transform the XML data into MS Word XML file:
In
the stylesheet you can include other data from NAV into the result
(Object/ResponsibilityCenter/Name, Object/CompanyInfo/Name) without
being part of the source XML file describing the form. I do not know
more info about that (I have no access to this new codeunit yet) but if
you can include any data from NAV, this will be very cool tool for
creating exports.
After you prepared some XSLT
template, you can import the template into NAV through Stylesheet setup
form. You need to select the xslt file, for which application the
stylesheet is prepared (which app will be launched, you can add your
own), the description and if the template is for all forms or just for
selected (depends on which option is selected on the setup card when
you run the import).


One
bigges issue I have with that is, that I am not able to find any
user-frendly tool for creating the stylesheet in some visual way (I am
novice in XSLT and XML things...). And second thing is that the logo
bitmap is part of the stylesheet and it means that you need to
customize the stylesheet for each customer. And because I have no good
tool for XSLT, I do not know how I can replace the bitmap in the
stylesheet...
I hope that after documentation
for NAV 5.0 is released, I will have more info to be able to create own
stylesheet and to work with that like with C/AL and that customization
of XSLT will be easy for me.
I do not know what will be in next part now.
All screenshots you can find in fullsize in my library at http://msmvps.com/photos/kine