Connect Session Templates
This document function defines named, pre-initialized Connect sessions. The primedocs web app can launch such a session directly from a URL and pre-populate form and data values — ideal for triggering a partially filled document creation from a third-party system (GEVER, CRM, custom application).
Related topics: primedocs Connect, Connect Session API.
Launching via URL
The web app launches a session via:
https://{instanz}/app/web/session/template/{Name}?Forms.Subject=...&Data.CustomerId=...
{Name} matches the Name attribute of the ConnectSessionTemplate. The GET parameters of the launching URL are merged into the resulting Connect object (Forms.* → Forms, Data.* → Data) and are available to the initializers.
Basic structure
<ConnectSessionTemplatesConfiguration>
<ConnectSessionTemplate Name="Quote">
<Initializers>
<CodeDataProvider>
<Code>
function main() {
return {
Forms: { Subject: $.parameter('Forms.Subject') },
Data: {}
};
}
</Code>
</CodeDataProvider>
</Initializers>
</ConnectSessionTemplate>
</ConnectSessionTemplatesConfiguration>
| Attribute / Element | Required | Description |
|---|---|---|
ConnectSessionTemplate/@Name | yes | Name of the template — used as the lookup key in the launching URL. |
Initializers | optional | Ordered list of initializers (see below). |
Commands | optional | Connect commands attached to the session (see below). |
GlobalInitializers/@Key | optional | Reference to a global initializers configuration. Mutually exclusive with inline Initializers (inline takes precedence). |
GlobalCommands/@Key | optional | Reference to a global commands configuration. Mutually exclusive with inline Commands (inline takes precedence). |
Initializers
The Initializers run in the defined order. Each initializer must return an object of the shape { Forms: { … }, Data: { … } }; the result is merged into the accumulating Connect object and is visible to the next initializer.
Available initializer types:
| Type | Description |
|---|---|
CodeDataProvider | Evaluates a JavaScript snippet and returns { Forms, Data } directly — without an external call. |
HttpDataProvider | Retrieves data via the DataService (OAuth/secret/multi-step HTTP logic). All URL parameters are automatically forwarded as search data. |
SqlDataProvider | Executes a SQL query via the DataService. |
ExcelDataProvider / CsvDataProvider | Reads an Excel or CSV file via the DataService. |
GlobalDataProviders/@Key | Inlines the initializers of a global configuration at this position. |
The $ object inside CodeDataProvider/Code provides:
| API | Description |
|---|---|
$.parameter(key) | Returns a URL parameter of the launching URL (e.g. $.parameter('Forms.Subject')). |
$.forms(key) | Returns an already-set Forms value. |
$.data(key) | Returns an already-set Data value. |
$.datasourceId | ID of the current data source. |
$.templateId | ID of the template. |
The service-based initializers (HttpDataProvider, SqlDataProvider, ExcelDataProvider, CsvDataProvider) use the same mechanism as the Select data interface. A Mapping configuration is not supported for initializers; the transformation happens in the Code element.
Commands
Commands attach Connect commands to the resulting session, grouped by the OnSuccess, OnExit, OnError and OnCancel events. In web sessions, the commands InvokeUrl (multi-step HTTP call to an external system) and ShowDialog (feedback dialog) are supported.
<Commands>
<OnSuccess>
<ShowDialog Title="Done" Message="The document has been created." ButtonLabel="OK" />
</OnSuccess>
</Commands>
InvokeUrl can require a connected service via the ConnectedServiceKey attribute. If the user is not signed in, the web app shows a login banner.