Structure
primedocs Connect is an XML interface that can be used to partially or fully automate document generation. Connect can be processed on both the client and server side.
<primedocsConnect>
...
</primedocsConnect>
Template
The Template-element can be used to specifically address a template or filter based on tags.
Id
The Id-attribute is used to select the template for document processing. The exact GUID of the template must be transferred as the specification for this.
<primedocsConnect>
<Template Id="30b55516-80b5-41d7-801b-b31d6da376ac" />
...
</primedocsConnect>
Version
The Version="Draft" attribute can be used to access a template in draft mode.
<primedocsConnect>
<Template Id="30b55516-80b5-41d7-801b-b31d6da376ac" Version="Draft" />
...
</primedocsConnect>
TagFilter
The TagFilter-element can be used to specify tags for filtering.
<primedocsConnect>
<Template>
<TagFilter>
<Tag>Tag1</Tag>
<Tag>Tag2;Tag3;Tag4</Tag>
</TagFilter>
</Template>
...
</primedocsConnect>
AND-links are defined within a tag element separated by semicolons, OR-links by several tag elements. The example above shows all templates that are marked with Tag1 or Tag2, Tag3 and Tag4.
ℹ️ Info By default, filtering is expected to return only one template as a result.
If the query returns several templates, an error message is displayed. In particular, during server-side processing, an error is returned if the query finds more than one template.
The AllowTemplatePicker attribute can be used to optionally display a selection dialog (“TemplatePicker”), which then shows all resulting templates.
<primedocsConnect>
<Template>
<TagFilter AllowTemplatePicker="true">
<Tag>Tag1</Tag>
<Tag>Tag2;Tag3;Tag4</Tag>
</TagFilter>
</Template>
...
</primedocsConnect>
The “TemplatePicker” is also displayed if no Template-element is specified.
DocumentLanguage
The target document language can be specified via the DocumentLanguage-element with the code attribute.
<primedocsConnect>
<DocumentLanguage Code="de-ch" />
...
</primedocsConnect>
ℹ️ Info If no
DocumentLanguageis specified, the default language of the primedocs data source is used.
DocumentLocation
The DocumentLocation-element in combination with the Source-attribute can be used to update a document previously created with primedocs.
Source can be a file path or a URL.
In the case of a URL, it must be approved in the dashboard via RemoteDocumentLocationPolicies.
Details and notes can be found under Updating documents .
<primedocsConnect>
<DocumentLocation Source="\\MyServer\share\doc\...\documentxyz.docx" />
...
</primedocsConnect>
Author
The Author-element can be used to start document generation with a specific profile and a specific theme.
<primedocsConnect>
<Author>
<Profile Id="08be85c8-d12a-4e8c-b1aa-9f56e5f6ed38" ThemeId="Red" />
</Author>
...
</primedocsConnect>
A specific profile can be selected via the Id-attribute. The ThemeId-attribute can be used to select a specific theme.
If no explicit profile is specified, the current profile of the primedocs client is used.
A profile must be specified on the server side, otherwise an error will be returned.
The required ProfileId and other technical information can be viewed directly in the detail dialog of the profile view.
Forms
The documentfunction Forms is used to query data before the document is generated. The configured properties can also be pre-filled via the Connect interface.
Attribute
| Attribut | Funktion |
|---|---|
| HideDialog | If the value is set to true, no dialog box is displayed and instead the default values and the values submitted in the connect request are used for document generation.> ℹ️ Info > If validation fails, for example, if an element marked as required has not been set, the document cannot be generated and a Connect error is generated. |
<primedocsConnect>
<Forms HideDialog="true">
<!-- "Simple" mappings to Text/Choice/Date/... -->
<Value Key="Subject">Sample letter</Value>
<Value Key="Note">Another sample</Value>
<!-- Target is an Object -->
<Object Key="Recipient">
<Value Key="Name">John Doe</Value>
<Value Key="Address">Sample Street 123, 12345 City</Value>
</Object>
<!-- Target is an ObjectCollection -->
<ObjectCollection Key="Topics">
<Item>
<Value Key="Name">Sample 1</Value>
</Item>
<Item>
<Value Key="Name">Sample 2</Value>
</Item>
<Item>
<Value Key="Name">Sample 3</Value>
</Item>
<Item>
<Value Key="Name">Sample 4</Value>
</Item>
</ObjectCollection>
</Forms>
...
</primedocsConnect>
Connect is only used to specify the “target ID” of the respective element together with the content. A distinction is made between 3 different types:
- “Normal” elements can be filled via
<Value Key="ElementId">Value</Value>. - Objects (
Object), such as personal details via the parent element<Object Key="ElementId" />together with<Value Key="ElementId">Value</Value>for the child elements. - Object lists (
ObjectCollection) for lists of data, where each data record is in anItem-element.
Multi-line texts
To transfer multi-line texts, the XML line feed element ( ) can be used or a new line can be inserted in the XML itself.
<Value Key="SampleWithLineFeed">Line1 Line2</Value>
<Value Key="SampleWithCData"><![CDATA[Line1
Line2]]></Value>
<Value Key="SampleWithoutCData">Line1
Line2</Value>
Data
In conjunction with the Data document function, Data can be used to transfer data via Connect that should not be displayed or queried in the Forms properties dialog beforehand.
<primedocsConnect>
<Data>
<!-- "Simple" mappings to Text -->
<Value Key="InternalId">123456789</Value>
<!-- FormattedText via Html (HtmlBase64 is also possible) -->
<Value Key="TextWithFormatting" Format="Html">
<![CDATA[
<p><b>Important:</b> This message...</p>
]]>
</Value>
<!-- WordContent via FlatOpc (FlatOpcBase64 or DocxBase64 is also possible) -->
<Value Key="TextWithWordFormatting" Format="FlatOpc">
<![CDATA[
<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
...
</pkg:package>
]]>
</Value>
<!-- Target is an Object -->
<Object Key="Invoice">
<Value Key="Name">John Doe</Value>
<Value Key="Number">123</Value>
</Object>
<!-- Target is an ObjectCollection -->
<ObjectCollection Key="Items">
<Item>
<Value Key="Name">Sample 1</Value>
</Item>
<Item>
<Value Key="Name">Sample 2</Value>
</Item>
</ObjectCollection>
</Data>
...
</primedocsConnect>
The logic here is identical to the transfer to forms, i.e. there are:
<Value Key="...">...</Value><Object Key="...">...</Object><ObjectCollection Key="...">...</ObjectCollection>
There is a special behavior of the target types WordContent and FormattedText. These types require an explicitly set format when the Connect call is made.
The following formats are supported for FormattedText:
- Html:
<Value Key="..." Format="Html">...</Value>, in this case, HTML is expected as text. - HtmlBase64:
<Value Key="..." Format="HtmlBase64">...</Value>, the content corresponds to the same HTML format, but is Base64 encoded.
The following formats are supported for WordContent:
- FlatOpc:
<Value Key="..." Format="FlatOpc">...</Value>, in this case, the content is expected to be in FlatOpc format as text. - FlatOpcBase64:
<Value Key="..." Format="FlatOpcBase64">...</Value>, the content corresponds to the same FlatOpc format, but is Base64 encoded. - DocxBase64:
<Value Key="..." Format="DocxBase64">...</Value>, the content can be a complete Word file in .docx format encoded in Base64.
Outlook
ℹ️ Info This element is only considered in connection with Outlook templates.
Outlook templates have several types or call types, so there is a separate element for handling these template types.
<primedocsConnect>
<Outlook ContentType="Html" />
...
</primedocsConnect>
ContentTypecontrols the template forHtmlorPlainText.
Commands
Commands can be applied after the actual document creation (e.g. conversion to a PDF document). At the same time, the error and abort commands are evaluated at document level.
Commands can be started after the following events:
OnSuccess: On successful document generation.OnError: If an error occurs during document generation, e.g. an incorrect template ID is specified.OnCancel: If the user cancels the document generation, e.g. via the Forms dialog.OnExit: After completion of the document generation, it does not matter whether everything ran successfully or not.
Sequence
The Command sequence depends on the status of the document generation:
- Success:
OnSuccess, thenOnExit - Error:
OnError, thenOnExit - Cancel:
OnCancel, thenOnExit - On Error in
OnSuccess:
OnError, thenOnExit
In the event of an error in OnError, OnCancel, OnExit:
- Immediate abort
Example:
<primedocsConnect>
<Template Id="30b55516-80b5-41d7-801b-b31d6da376ac" />
<Forms>
<Value Key="Subject">Hello Connect</Value>
</Forms>
<Commands>
<OnSuccess>
<SaveFile FileName="\\MyServer\share\organization\...\documentxyz.docx"
Overwrite="true"
CreateFolder="true">
<Document />
</SaveFile>
</OnSuccess>
</Commands>
</primedocsConnect>
In this example, a document is generated with the template 30b55516-80b5-41d7-801b-b31d6da376ac with the Subject “Hello Connect”.
After successful document generation, the document is saved to a folder using the SaveFile- command.
All available commands are documented here: After document generation (Commands)
XSD-Schema
Below you will find the schematic in XSD format:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="primedocsConnect">
<xs:complexType>
<xs:sequence>
<xs:element name="Template">
<xs:complexType>
<xs:sequence>
<xs:element name="TagFilter">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Tag" type="xs:string" />
</xs:sequence>
<xs:attribute name="AllowTemplatePicker" type="xs:boolean" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" type="xs:string" use="optional" />
<xs:attribute name="Version" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="DocumentLanguage">
<xs:complexType>
<xs:attribute name="Code" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="DocumentLocation">
<xs:complexType>
<xs:attribute name="Source" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="Author">
<xs:complexType>
<xs:sequence>
<xs:element name="Profile">
<xs:complexType>
<xs:attribute name="Id" type="xs:string" use="required" />
<xs:attribute name="ThemeId" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Forms">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Value" type="ValueElement" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="Object" type="ObjectElement" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="ObjectCollection" type="ObjectCollectionElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Data">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Value" type="ValueElement" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="Object" type="ObjectElement" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="ObjectCollection" type="ObjectCollectionElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Outlook">
<xs:complexType>
<xs:attribute name="ContentType" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="Commands">
<xs:complexType>
<xs:sequence>
<xs:element name="OnSuccess">
<xs:complexType>
<xs:sequence>
<xs:element name="SaveFile" minOccurs="0" maxOccurs="1" type="CommandSaveFileElement" />
<xs:element name="OpenFile" minOccurs="0" maxOccurs="1" type="CommandOpenFileElement" />
<xs:element name="InvokeProcess" minOccurs="0" maxOccurs="1" type="CommandInvokeProcessElement" />
<xs:element name="InvokeUrl" minOccurs="0" maxOccurs="1" type="CommandInvokeUrlElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OnError">
<xs:complexType>
<xs:sequence>
<xs:element name="SaveFile" minOccurs="0" maxOccurs="1" type="CommandSaveFileElement" />
<xs:element name="InvokeProcess" minOccurs="0" maxOccurs="1" type="CommandInvokeProcessElement" />
<xs:element name="InvokeUrl" minOccurs="0" maxOccurs="1" type="CommandInvokeUrlElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OnExit">
<xs:complexType>
<xs:sequence>
<xs:element name="SaveFile" minOccurs="0" maxOccurs="1" type="CommandSaveFileElement" />
<xs:element name="InvokeProcess" minOccurs="0" maxOccurs="1" type="CommandInvokeProcessElement" />
<xs:element name="InvokeUrl" minOccurs="0" maxOccurs="1" type="CommandInvokeUrlElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OnCancel">
<xs:complexType>
<xs:sequence>
<xs:element name="SaveFile" minOccurs="0" maxOccurs="1" type="CommandSaveFileElement" />
<xs:element name="InvokeProcess" minOccurs="0" maxOccurs="1" type="CommandInvokeProcessElement" />
<xs:element name="InvokeUrl" minOccurs="0" maxOccurs="1" type="CommandInvokeUrlElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Data / Forms Element Types -->
<xs:complexType name="ValueElement">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Key" type="xs:string" use="required" />
<xs:attribute name="Format" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ObjectElement">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Value" type="ValueElement" />
</xs:sequence>
<xs:attribute name="Key" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="ObjectCollectionElement">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Item">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Value" type="ValueElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Key" type="xs:string" use="required" />
</xs:complexType>
<!-- Command Types -->
<xs:complexType name="CommandSaveFileElement">
<xs:sequence>
<xs:element name="Document" minOccurs="0" maxOccurs="1" type="DocumentElement" />
<xs:element name="Report" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="FileName" type="xs:string" use="optional" />
<xs:attribute name="field-FileName" type="xs:string" use="optional" />
<xs:attribute name="Overwrite" type="xs:boolean" use="optional" />
<xs:attribute name="CreateFolder" type="xs:boolean" use="optional" />
</xs:complexType>
<xs:complexType name="CommandOpenFileElement">
<xs:attribute name="FileName" type="xs:string" use="optional" />
<xs:attribute name="field-FileName" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="CommandInvokeProcessElement">
<xs:sequence>
<xs:element name="Arguments" minOccurs="0" maxOccurs="1" type="ElementWithFieldSupport" />
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="CommandInvokeUrlElement">
<xs:sequence>
<xs:element name="Step" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Request">
<xs:complexType>
<xs:sequence>
<xs:element name="Url" minOccurs="0" maxOccurs="1" type="ElementWithFieldSupport" />
<xs:element name="Body" minOccurs="0" type="ElementWithFieldSupport" />
<xs:element name="Header" minOccurs="0" maxOccurs="unbounded" type="CommandInvokeUrlElementRequestHeaderOrFormElement" />
</xs:sequence>
<xs:attribute name="Method" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="MultipartFormDataRequest" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="File">
<xs:complexType>
<xs:sequence>
<xs:element name="Document" minOccurs="0" maxOccurs="1" type="DocumentElement" />
<xs:element name="Report" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="optional" />
<xs:attribute name="ContentType" type="xs:string" use="optional" />
<xs:attribute name="FileName" type="xs:string" use="optional" />
<xs:attribute name="field-FileName" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="Url" type="ElementWithFieldSupport" />
<xs:element name="Header" maxOccurs="unbounded" minOccurs="0" type="CommandInvokeUrlElementRequestHeaderOrFormElement" />
<xs:element name="FormData" maxOccurs="unbounded" minOccurs="0" type="CommandInvokeUrlElementRequestHeaderOrFormElement" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Response" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Property" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="JsonPath" type="xs:string" use="optional" />
<xs:attribute name="XPath" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CommandInvokeUrlElementRequestHeaderOrFormElement">
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Value" type="xs:string" use="optional" />
<xs:attribute name="field-Value" type="xs:string" use="optional" />
</xs:complexType>
<!-- Common Elements -->
<xs:complexType name="ElementWithFieldSupport">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="field-Content" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="DocumentElement">
<xs:attribute name="Conversion" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>