Office Templates
Introduction
The Office Templates module allows you to manage document templates (Word, Excel) that will be merged with form data. This enables automatic generation of letters, reports, or contracts in Office format.
Accessing Templates
This feature is generally located in the Forms section of Process Studio.
- Open the Forms section.
- Click on the Office Templates section.
Creating a Template
1. Preparing the Office File (Word/Excel)
Process Studio uses Microsoft Office Bookmarks to locate where to insert data.
For simple fields:
- In Word, position your cursor at the desired location.
- Go to the Insert tab > Bookmark.
- Give your bookmark a name (e.g.,
Signet_Client) and validate.Tip: Display bookmarks in Word options (Options > Advanced Options > Show document content > Bookmarks) to visualize them between brackets
[ ].
For tables (Repeating rows):
- Create a table in Word with a header row and only one content row.
- In this content row, insert a bookmark in each cell that should receive data from a column of your form table.
Example: In the "Quantity" cell, insert the bookmark
Signet_Qte. - The system will automatically duplicate this row for each element in your table/grid during generation.
2. Configuration Interface
The template editor allows you to define properties and establish the link between bookmarks and data.

Advanced Properties
- File name format: Defines the name of the generated document. You can use the expression builder (
ABbutton) to insert field values (e.g.,[Reference]-[NomClient].docx). - Additional DLLs: Allows referencing external assemblies if you use specific classes in your C# scripts.
- Visible in form:
- Yes: Always visible.
- No: Never visible (internal use or via workflow only).
- Conditional: Visible only if a C# expression returns
true.
3. Creating the Mapping
The "Mapping" panel lists all bookmarks detected in your Office file. For each bookmark, you must define the Mapping Mode (Right panel):
A. Direct Mapping (Field)
This is the simplest case.
- Select the bookmark in the list.
- Check Field on the right.
- Choose the form field from the dropdown list.
B. Custom Rule (C# Script)
For more complex needs (formatting, calculation, SQL query), use the Custom rule mode. Here are some common examples:
Example 1: Date Formatting
DateTime? date = doc.GetDateValue("DateAnalyse");
if(date.HasValue)
return string.Format("{0:dd/MM/yyyy}", date.Value);
else
return "";
Example 2: SQL Data Retrieval Allows fetching related information from the database.
Avanteam.Application.DataSource.ApplicationDataSource appDataSrc = new Avanteam.Application.DataSource.ApplicationDataSource();
System.Data.DataTable dt = appDataSrc.DocumentsDataSource.SQL_ExecuteSelect(
@"select
D.title,
dbo.GetShortName(FRM.Pilote),
convert(varchar, FRM.DateLimite, 106),
dbo.LocalizeWorkflowActivity( idFiche , '**' )
from FRM_LD_DocsTab LD
inner join Documents D on D.id=LD.idFiche
inner join FRM_Action FRM on FRM.id_document=LD.idFiche
where LD.id_document=@idDoc order by D.title asc",
new KeyPair("idDoc", doc.GetStringValue("id_document")) );
return dt;
Example 3: Directory Information (Full Name) To display a user's full name from their login/directory field.
var fullName = doc.GetStringValue("Emetteur") ?? "";
return ApplicationDataSource.DirectoryDataSource.GetDirectoryResourceInfos(fullName,
Directory.DataSource.GetDirectoryResourceInfosOptions.KeepNotFoundEntriesWithDisplayNameAsFullName)
.DisplayName;
Example 4: Workflow History Displays the user who performed a specific step, except in case of rejection or loop.
string nomEtape = "Analyse";
string action = FormatWorkflowHistory(nomEtape,"{action}","");
if ( action.Contains( "Refusé" ) || action.Contains( "Changement d'étape" ))
return "";
return FormatWorkflowHistory( nomEtape, "{user}", "");
- Save the template.
Usage
Once the template is imported and configured, it can be used to generate the document:
- Via a "Print / Generate" action button located on the form.
- Via an automatic workflow step "Document generation".
- Via automatic email (sending the generated document as an attachment).
The engine replaces the template bookmarks with form values at generation time.