Document with sub-documents
If you want to add data from another data collection to a document layout, you can use a sub-document. The subdocument is a seamless component of the letter.
Note:
You cannot include a subdocument in another subdocument. You can, however, include multiple sub-documents in the main document.
|
Contents |
Subdocument for a list with data
Suppose you want to draft a letter to an employee that includes of list of his absence entries. The document layout is based on the main data collection Employee (Current data incl. authorisation). On each line (record), this table contains the current data for a single employee.
You add the data collection with absence entries. This data collection may contain multiple absence entries (records) for each employee. The relationship between these tables is also called a 1:n relationship. You can see an example of this relationhsip in the image below.

You must also define the link between the two tables in the document layout. This means every letter will contain the absence entries of the employee in question. If you do not define this link, then every letter will contain ALL of the absence entries (i.e. including absence entries from other employees).
Subdocument for a list of data:
- In the Word document, put the cursor at the location where you want to insert the subdocument.
- Click on: Data collection in the Profit document generator toolbar.
- Click on: New subdocument.
- Select the data collection.
- Click on: Next.
- Set the link between the main data collection and the new data collection.
You can change the link later on using the Profit document generator toolbar.
If the desired field is not available, then you must first complete and exit the wizard. Then add the field to the data collection. Finally, customise the link.
- Click on: Next.
- If necessary, customise the name of the data collection. Profit uses this name to put markers in the document. A short name is easier to use in the document.
- Click on: Finish.
Profit puts start and end markers for the new subdocument in the document layout.

Note:
In this situation, the markers must be on different lines (as Profit inserted them). By default, the marker is followed by a hard return (Enter), but you can also use a carriage return (Shift+Enter).
- Put the desired fields from the new data collection between the markers.
- If multiple lines (records) may get created when generating the document, you can put them in a table:
- Put a table row with descriptions above the markers.
- Copy this row and put it between the markers.
- Put the Profit fields in the row between the markers.

- Specify a sorting for lines in the subreport. From the Profit document generator toolbar, go to the data collection and select Sorting.
- Test the document layout using the Generate button.

Subdocument with a specific embedded entry
A subdocument can also be embedded in text as long as the start and end markers are present. If you embed the markers in text, then they must be in the same paragraph. Another option is to put the markers on separate lines, without text after them.
Example:
In a letter to an employee, you want to add the name of the lease company for his leased vehicle.
You add the Fleet data collection. By defining a link based on employee = employee, the letter generated will only contain the lease company for the leased vehicle of the employee who is the addressee.

In this situation, you can also put the entire paragraph between markers. If the employee has a leased vehicle, then the entire paragraph will be shown in the generated letter. If the employee does not have a leased vehicle, then the entire paragraph will be left out of the generated letter because the subdocument is not shown at all.

Re-insert or restore start and end markers
If you (accidentally) delete the start and end markers, you can re-insert them. If the markers are not present but fields from the subdocument are in fact present, then the document cannot be generated.
To re-insert start and end markers:
- Put the cursor at the desired location in the document.
- Click on Data collection in the Profit document generator toolbar.
- Go to the data collection and click on Insert marks.

|
Directly to |