ID: ZTN4417
This Zetadocs technical note applies to:
- Version 7.0 of Zetadocs for NAV and later
- Zetadocs for NAV Delivery Essentials or Zetadocs for NAV Delivery Plus
Summary
This article demonstrates how you can use the GetOutputFileName to change the name of the file that Zetadocs for NAV outputs based on the language of the customer who will be receiving it.
Out of the box Zetadocs names attachments in the language of the NAV system itself. An English language system will output names like “Sales Order-12345”. This document discusses updating the Codeunit 9009962 “Zetadocs-Send Integration” to look up the language of the customer and output a filename in the customer’s preferred language.
To do this, the code will need to look up the “Language Code” field of the customer, and looks that up in the “Languages” table to obtain the “Windows Language ID” field, which is then used to create a string in the language of the customer that can then be used as the filename. If the customer does not have a language code set, the output filename will default to the language that NAV is configured for.
The “GetOuptutFileName” method that will be modified has different sections for each of the types of record that can be exported. This article covers updating the output filename from Sales Header record, but this technique can be applied to any of the other record types.
More information
The steps below have been written for an environment which has Dynamics NAV 20015 installed and configured with Zetadocs. Similar steps may apply to other versions of Dynamics NAV.
Open the Zetadocs-Send Integration Codeunit
- In the NAV Development Environment, navigate to Codeunit 9009963 – Zetadocs-Send Integration and click “Design”
- Scroll to the “GetOutputFileName” function
- Go to Tools > C/AL Locals > Variables
- Add the following variables:
- lang – Record – Language
- cust – Record – Customer
- retStr – Text – 250
- windowsLangId – Integer
- In the code, navigate to the Record Type that you want to update the output filename for (ie. For Sales Headers, navigate to the line that reads “36: //"Sales Header"”
- Remove the line that reads “EXIT(STRSUBSTNO(‘%1-%2 %3’, strSales, FORMAT(fieldRef2), fieldRef.VALUE));” – this is the line that creates the default file name.
- Paste the following code in its place:
//Load customer object to find language code
custRef := RecRef.FIELD(2);
cust.GET(custRef);
IF lang.GET(cust."Language Code") THEN
windowsLangId := lang."Windows Language ID"
ELSE
windowsLangId := 0;
CASE windowsLangId OF
ELSE //All other/unknown language
retStr := ‘Sales Order-%1’
END;
EXIT(STRSUBSTNO(retStr, fieldRef.VALUE));
- Look up the Locale ID(s) that you want to support on the “Locale Ids Assigned by Microsoft” article here: https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx – and select the “LCID Dec” value. For example, supporting French and German, you would get 1036 and 1031.
- Copy the following lines and paste them below “CASE windowsLangId OF” and before the “ELSE” line – repeating this process for each language you want to support
9999: //Place Locale ID here
retStr := 'Language - %1';
- Replace the 9999 ID with the Locale ID, and set retStr to the output file name that is correct for the language. For example, to support French and German, you would end up with lines like this:
1036: //French
retStr := 'Confirmation De Commande - %1';
1031: //German
retStr := 'Auftrags - %1';
- Your code should now look like this:
- Update the language in the “ELSE” statement to reflect the customer’s default language
- Compile the Codeunit by pressing F11
Test your system
You are now ready to test your work.
- Ensure you have a customer with a language set to a supported language
- Print a record that is supported by the changes made to the Codeunit
- You should now see the filename of the attached file is in the correct language
- Repeat the test with a customer that does not have a language set
- You should now see the filename of the attached file is in the correct language
References
Use the Zetadocs for NAV Installation guide for further details on the functions used in this article.
Last updated: 15th June 2015 (LA/NT)
Keywords: Zetadocs Customize