In Connectivity studio, use a Microsoft Word document to write data to a Microsoft Word document (DOCX) using a Microsoft Word template (DOTX).
With a Microsoft Word document, you can, for example, add data to text, include contract text, support multi-language output, or include product attributes or specifications. In this way, you can, for example, generate invoices or contracts with the style texts as defined in the template.

To add data to the Microsoft Word document, you can add markers to the Microsoft Word template. You can add markers for document records and for document record fields.

Note: You can use a Microsoft Word document only to write. So, no read options need to be set.


Standard procedure

1. Click Connectivity studio Integration Design.
2. Click the Documents tab.
3. Click New.
4. Define a meaningful name for the document.
Example: If the document is used for a sales integration, you can use names like 'Sales - Order' or 'Sales - Invoice'.
  In the Document field, type a value.
 

Note: Best practice: In the document name, do not use the:
- Application: Use the Application field to define the applicable application.
- Document type: Use the Document type field to define the applicable document type.

5. In the Project field, enter or select a value.
6. Define the applicable application for the document. For a Microsoft Word document, for example, select a 'Windows folder' or 'Files' application.
  In the Application field, enter or select a value.
 

Note: You can only select an application that is defined for the applicable project. You can define project applications on the Projects page.

7. In the Document types field, select 'Microsoft Word'.
8. Sub-task: Set properties.
  8.1 Expand the Properties section.
  8.2 You can process an external document in these ways:
- Direct: You can use this to import or export (big sets of) simple data. For simple data, the document lines only have a root record. When a message is run, the data is directly mapped. More technically: it only loads the data in the memory of the record table (usually the BisBufferTable). As a result, the import or export of data is faster.
- Query: You can use this to import or export complex data. For complex data, the document lines have several records and parent-child relations. When a message is run, the records are stored in the record table (usually the BisBufferTable) before the data is mapped. When the message run is finished, the records are deleted from the record table.
  In the Process type field, select an option.
  8.3 To apply a predefined layout to your Microsoft Word files, define a Microsoft Word template file of type DOCX or DOTX to create a Microsoft Word file. On data export, based on this template, a file is created to which the data is exported.
  In the Template filename field, enter or select a value.
  8.4 You can indicate the language of the document to be created. On write, the field labels for the defined language are used. This can be useful for language-specific documents.
  In the Language field field, enter or select a value.
9. Sub-task: Set custom handler.
  9.1 Expand the Custom section.
  9.2 For a Microsoft Word document, the standard handler class is 'BisDocumentWord'. This handler class writes data to Microsoft Word files using Open XML.
You can use a customized handler class. To do so, extend a standard handler class.
  In the Handler field, enter or select a value.
 

Note: Select the 'BisDocumentWordV3' handler, if you, on a message, use the XML document in combination with a connector of one of these types:
- Web service
- Blob storage
- Upload and download
- SharePoint

10. Sub-task: Set write options.
  10.1 Define the filename settings based on which filenames are created when exporting data to files.
  Expand the Write section.
  10.2 Using a variable, you can add the value of two table fields to the filename. If you want to do so, define the applicable table.
On write, this document is the target document. However, the file name is defined based on the root record values of the source document. So, make sure you select a table and table fields from the root record of the applicable source document.
  In the Table name field, enter or select a value.
 

Note: You cannot use the table name itself as variable in the filename.

  10.3 Define the first table field which value you want to add to the file name. The related variable is '%5'.
  In the First field field, enter or select a value.
 

Note: You can only select a field from the defined table.

  10.4 Define the second table field which value you want to add to the file name. The related variable is '%6'.
  In the Second field field, enter or select a value.
 

Note: You can only select a field from the defined table.

  10.5 To make the filename unique, you can add a unique number to the filename, provided by a number sequence. The related variable is '%4'.
  In the Number sequence field, enter or select a value.
  10.6 Define the filename for the files that are created based on the document.
You can use fixed values and variables. The available variables are:
- %1: The name of the current document.
- %2: The current date.
- %3: The current time.
- %4: The unique number as provided by the defined number sequence.
- %5: The value of the defined First field
- %6: The value of the defined Second field
- %7: The ID of the current company.
- %8: The ID of the current user.
- %9: The file extension as defined by the applicable document type. In this case, it is 'docx'.
- %10: The UTC internet date/time (RFC3339 with underscores). Example: 2021-01-05T14_38_51Z
  In the Write filename field, type a value.
11. Sub-task: Set document properties.
  11.1 You can set the Microsoft Word file properties in the document to make upload of a generated file to SharePoint easier.
  Expand the Document properties section.
  11.2 If you have defined a template filename, you can read the properties from the template and upload these to the document.
  Click Read properties.
  11.3 You can manually add properties that are used to set the Microsoft Word file properties on creation.
  Click New.
  11.4 Enter the name of the property.
  In the Name field, type a value.
  11.5 Indicate if the property is a standard Microsoft Word property (Core) or a customized property (Custom).
  In the Type field, select an option.
  11.6 You can enter a fixed value for the property.
  In the Value field, type a value.
  11.7 You can use a table field to define the property value on creation of the Microsoft Word file.
You can only use a table field of the table as defined in the Write section, in the Table name field.
  In the Field name field, enter or select a value.
  11.8 If you have defined a template filename, you can update the properties of the template based on the properties as defined for the document.
  Click Write properties.
12. Sub-task: Set conditional templates.
  12.1 You can use conditional templates help to generate documents for different types or different languages. For example, if templates have contract disclaimers which can be language specific. Use a range to define the condition.
  Expand the Conditional templates section.
  12.2 Click New.
  12.3 Define the field based on which value a conditional template is applied. For example, a language field.
  In the Field name field, enter or select a value.
 

Note: You can only use fields of the table as defined in the Write section, in the Table name field.

  12.4 Define the field value based on which a conditional template is applied.
  In the Range field, enter or select a value.
  12.5 Define the Microsoft Word template file of type XLSX or XLTX that is applied for the defined condition.
  In the Template filename field, type a value.
13. Close the page.

See also

Provide feedback