Data sources and relationships
In short
Every template prints from a primary source: the table in Dynamics for whose records the document is created, such as “Angebot”. Through relationships you reach connected records, for example the customer or the items; the designer fetches them from Dynamics itself. Additional sources bring in whole tables that are not connected to the document, such as the list of currencies. All of this is on the left in the data tree (see Data tree and field picker), and from there you drag fields into the template.
The primary source
The primary source is the table the template prints from. Printing is always for exactly one record of this table, such as the quote on which someone clicks the button in Dynamics, or the record a flow passes on (see Buttons: the assistant). The fields and relationships the data tree offers you come from the primary source. In the “Manage data sources” window it is at the very top, with a ★ before the name. In the data tree it is the first source below “Custom variables” and “System variables”, with a ★ after the name.
You usually set the primary source when you create the template (see Creating a new template); without it, “Continue to settings →” stays blocked there. A document is also never created without a primary source.
Setting the primary source
- Click “★ Set primary source”. You find the button in the “Manage data sources” window as long as there is no primary source yet, and in the “Primary source required” window. The “Choose a table” window opens.
- Type part of the table name, such as “Angebot”, and click the table. The “Choose sample record” window opens.
- Click the record you want to check the template with. You can also choose “Continue without a sample record” and add it later. The designer loads the fields of the table (“Loading data source...”, then “Loading sample data...”) and reports “Source »Angebot« added.”. The source is at the very top in the “Manage data sources” window, with ★ before it, and in the data tree as the first source below “Custom variables” and “System variables”, with ★ after it.
- If you started in the “Manage data sources” window, click “✓ Confirm” there. Then save the template.
- The source has the same name as the table in Dynamics. It cannot be renamed in the designer.
- If you close one of the two selection windows with the Esc key or a click next to it, no source is created.
- The primary source is fixed as soon as it has been created: it has no ✕ and cannot be swapped for another table. As long as you have not confirmed in the window, “Discard” takes it back (see Confirming, discarding, closing).
- If the template already has content but no primary source yet, for example after importing a template without sources, the designer then checks whether the fields in the content match the new table. If something is left open, the “Assign variables” window opens (see The “Assign variables” window).
Tip
If you need the same design for another table, create a new template with the other table as its primary source and take over the content with copy and paste (see Working on the canvas: Copying, pasting and deleting). The “Assign variables” window then helps you move the fields over to the new table.
The “Choose a table” window
In this window you choose the table for the primary source or for an additional source.
| Control | What it does |
|---|---|
| Search box “Search… e.g. Account, Contact, Invoice” | Searches as you type in the name of the table and in its internal name. An exact hit is at the very top, then hits at the beginning of a name, then at the beginning of a word, then anywhere in the name; shorter names come first. At most 50 hits appear. When it opens, the cursor is already in the box. |
| Hit list | The name of the table in bold, its internal name in gray after it. A click chooses the table and closes the window. The tables offered are those Dynamics releases for advanced search. |
| “✕” at the top right | Closes without creating a source. A click next to the window and the Esc key do the same. |
Depending on the situation, the list says “loading tables…”, before the first input “Type to search for a table — e.g. Account, Contact, Invoice.” with the number of available tables, without hits “Nothing found.” and on an error “The tables could not be loaded. Please close the window and try again.”. If it says “(0 available)”, reload the designer; if that does not help, clarify your rights with your administrator (see Rights and roles). The designer always reads tables and fields with your sign-in and your rights.
The “Primary source required” window
This window opens by itself when you open a template without a primary source and when you call the full preview or the PDF while the primary source is missing. If there is no template at all yet, the “Welcome to Smart Templates” window appears instead (see Managing templates: When there is no template yet). This window says: “Every document needs a primary source — the table it is created from. Please set it now; this window can only be closed afterwards.”
- 1The only button: It starts setting the primary source.
- The window has no ✕, and neither the Esc key nor a click next to it closes it. It disappears as soon as a primary source has been set.
- Its only button “★ Set primary source” starts setting it as above. If you cancel in the process, the window stays.
- This way the primary source applies immediately, without “✓ Confirm”. Then save the template.
- If the full preview or the PDF opened the window, it does not carry on by itself after you have set the source: click “Full preview” or “PDF” again. If you chose a sample record while setting it, the designer then no longer asks for one (see Full preview and PDF: Without a primary source).
The “Manage data sources” window
In this window you set up the sources of a template: the primary source, the additional sources and the sample record. You do not create relationships and rules here; they are in the data tree (see Data tree and field picker: The data tree). You open the window in three ways:
- on the left above the data tree with “⚙ Manage data sources”,
- in the template settings in the “Data” tab with “⚙ Manage data sources”; if the primary source is still missing, the button is called “★ Set primary source” and is blue, but also opens this window (see Template settings),
- when creating a new template in step 1 with “⚙ Choose data source …”; if the primary source is already set, the button is called “⚙ Manage data sources — Primary source: …”, with additional sources with the suffix “· … more”.
The window opens over a window that is already open, such as the template settings. On the left are the sources, on the right the record from Dynamics, at the bottom the buttons for confirming and discarding.
- 1The primary source, with ★ before the name. Below it the internal name of the table and the sample record.
- 2The ✕ exists only on additional sources. It removes the source after a confirmation question.
- 3Adds an additional source: a whole table that is loaded as a list.
- 4Header bar of the chosen source: name, sample record and the buttons for choosing, removing and opening in Dynamics.
- 5The frame. In Dynamics it shows the real page of the record; here it is left empty.
- 6On the left the state of the changes, on the right “Discard” and “✓ Confirm”. Only “✓ Confirm” takes the sources over into the template.
On the left: the sources
| Control | What it does |
|---|---|
| “★ Set primary source” | Blue, only as long as there is no primary source. Above it it says “No primary source yet. Choose the table this template prints from — fields and relationships then come from Dynamics.”. The button starts setting it (see above). |
| Row of a source | The name of the source in bold, for the primary source with ★ before it. Below it, in gray, the internal name of the table and a suffix. For the primary source this is “Example: …” with the name of the sample record, “Example: without a name · …” with the first eight characters of its identifier if it has no name, or “no sample record”; in case of a fault, “⚠ Record missing” or “⚠ could not be read (…)” is added in red (see below). For an additional source it says “List (all rows, at most 50 on the canvas)”. A click on the row shows the source in the right half; when it opens, the primary source is chosen. |
| “✕” in the row | Red, only on additional sources. Removes the source after a confirmation question (see Removing an additional source). |
| “Additional source” | Button with a database symbol below the list, as soon as there is a primary source. Adds an additional source (see Additional sources). |
| Note with ⓘ | “The primary source is fixed. Every additional source is a list, not a single record.” The ⓘ explains how you get values from an additional source. |
On the right: the record from Dynamics
The right half shows the source that is chosen on the left. If there is no source yet, it says “Choose a data source on the left — its record from Dynamics will appear here.”.
| Control | What it does |
|---|---|
| Header bar | The name of the source, for an additional source with “· List”. Next to it, for an additional source, it says “This source prints ALL rows of the table.”, for the primary source “Sample record: …” with its name, where applicable with “⚠ no longer exists in Dynamics” or “⚠ could not be read (…)”. If the sample record is missing, it says “No sample record — the records of »…« are listed below — choose one.”. You can choose only with the button “Choose record”, not in the frame below it. |
| “Choose record” or “Choose another record” | Only for the primary source. Opens the “Choose sample record” window (see below). After the choice, the designer rebuilds the sample data and reports “Sample record set: …”. A cancel or “Continue without a sample record” change nothing. The record is saved with the template; the choice therefore counts as a change and applies only with “✓ Confirm”. |
| “Remove” | Only for the primary source with a sample record. Takes it out of the template without a confirmation question and rebuilds the sample data (“Resetting sample data...”); the additional sources stay loaded. This changes nothing about the document that is printed in Dynamics. “Discard” brings it back. |
| “↗ Open in Dynamics” | For every source. Opens the same page as the frame in a browser tab of its own, for example when the frame shows nothing. |
| Frame with the page from Dynamics | Shows the form of the sample record; without a sample record and for an additional source, the list of the table, in each case without the navigation bar of Dynamics. The frame shows the real page from Dynamics and is for viewing. The template does not change through anything you do in it. |
Confirming, discarding, closing
What you change in the window you see in the data tree immediately. But it is taken over into the template only with “✓ Confirm”, and stored in Dynamics only with “Save” in the template row (see Managing templates: The template row). Therefore close the window with “✓ Confirm”, not with “Close”: If there are unconfirmed changes, the designer otherwise asks “Leave this window?”, and with “Leave and discard” they are gone, also a primary source you have just set.
| Control | What it does |
|---|---|
| “No changes” or “● Unconfirmed changes” | At the bottom left. Compares the sources with the state when the window was opened or after the last “Discard”. |
| “Discard” | Without a change, the designer reports “There is nothing to discard.”. Otherwise it asks “Discard all changes to the data sources?” with “Cancel” and “Discard”. Afterwards the sources are as when opened, the sample data is reloaded, and it reports “Reset.”. The window stays open. |
| “✓ Confirm” | Takes the sources over into the template and closes the window. The designer reports “Data sources applied — press »Save« to store them in Dynamics.” or “No changes.”. Everything you changed in the window is then a single step for Ctrl+Z (see Working on the canvas: Undo and redo). |
| “Close” at the top right, Esc key | Without a change, the window closes immediately. With a change, the designer asks in the “Leave this window?” window: “You have changes to the data sources that have not been confirmed yet. Leave anyway? The changes will be lost.” “Leave and discard” resets the sources and closes; “Back”, the Esc key or a click next to it lead back into the window. A click next to the window itself does not close it. |
Good to know
If you opened the window from the template settings, the confirmed work on the sources belongs to their state: “Apply” there keeps it, “Cancel” and then “Discard” take it back too (see Template settings).
When creating a new template, the message after “✓ Confirm” also says “Save”. But there you cannot save yet; you carry on with “Continue to settings →” and “Create template” (see Creating a new template).
The sample record
The sample record is a real record of the primary source, such as a particular quote. You check the template with it: The full preview and the PDF from the designer show its values. On the canvas, by contrast, fields appear as a blue marker with their name. What is printed in Dynamics is the record for which a button or a flow prints: the record on whose page the button is clicked, in a list the checked rows, and if the button sits on another table, the record at the end of its path (see Buttons: the assistant); for a flow, the record it passes on. How the full preview differs from printing in Dynamics is described under Full preview and PDF: Full preview and printing in Dynamics.
- In the background the canvas calculates with the data of the sample record, for example for images from data fields, for the version of a text that it shows (see Texts: Content depending on a condition), for the image an image rule chooses (see Images), for the results of rules and for the preview in the window of a variable.
- When keeping warm, Smart Templates creates its test documents with this record; if it is missing, with any record of the table (see Template settings).
- The sample record is saved with the template. Only the primary source has one; an additional source is a list.
- If none is saved, the designer asks for one before every full preview and every PDF. If you choose one there, it is saved and stored with the template (see Full preview and PDF: What is checked before creating). In the template settings there is the note “Without a saved record, the designer asks for one before every full preview and every PDF.”
- Open “Manage data sources”, choose the primary source on the left and click “Choose record” or “Choose another record” on the right.
- In the “Choose sample record” window, find the record and click its row. The designer shows “Loading sample data...” and then reports “Sample record set: …”.
- Click “✓ Confirm” and save the template.
The same works in the template settings in the “Data” tab, section “Sample record”, with “Choose sample record” or “Choose another sample record”, “↗ Open in Dynamics” and “Remove” (see Template settings). The buttons work like the corresponding ones in the “Manage data sources” window (see On the right: the record from Dynamics); you take a change back there with “Cancel” and “Discard”.
Tip
Check your template with several sample records: a customer with a long name, a quote with many items, a record in which fields are empty. That way you see whether everything fits before others print with it.
The “Choose sample record” window
The window is called “Choose sample record · …” with the name of the source. It opens through the buttons above, when setting the primary source and by itself before the full preview and the PDF if no sample record is saved or the saved one has been deleted in Dynamics. The records appear as a table with the columns of a view from Dynamics.
- 1Searches shortly after the last keystroke in the text columns of the view shown.
- 2The views of the table from Dynamics. The view determines the columns and the search columns.
- 3How many columns the view has; at most eight are shown.
- 4Closes the window without a choice.
- 5The records. A click on a row saves this record.
| Control | What it does | Default |
|---|---|---|
| Search box “Search…” | Searches shortly after the last keystroke in all text columns of the view shown; a hit must contain the search text. If the view shows no text column, the name is searched. The % character stands for any characters. | empty; the cursor is in the box |
| “View:” | The views of the table from Dynamics. First your own views with the suffix “(personal view)”, then the default view, the other main views and last the Quick Find view with “(Quick Find)”, within these groups in alphabetical order. The view determines the columns of the table and the columns that are searched. The designer cannot find out which view you last used in Dynamics; that is why you choose here. If Dynamics returns no list of views, the selection is missing together with “View:”; the window then picks a view of the table itself or shows only the name. | the first view in the list |
| Display next to the view | “loading…”, “loading view…”, then for example “5 columns” or “8 of 33 columns”; without columns “no columns — name only”. At most the first eight columns of the view are shown; columns that a view fetches from a linked table are not shown by the window. When you point at it with the mouse, the display gives the name of the view. | – |
| “Continue without a sample record” | Closes the window without a choice. When setting the primary source, the source is then created without a sample record; before the full preview and the PDF, the document carries on without a new record; otherwise everything stays as it was. | – |
| Table of records | The columns of the view; if the view does not show the name, a “Name” column is added at the front. Sorted by name, numbers and amounts right-aligned. A click on a row saves the record. With the Tab key you can also reach the rows by keyboard; the Enter key or the Space bar chooses. If the record has no name, the name column says “(no name)”, and the first filled-in value of the row becomes its label. It is always fetched by its internal identifier. | – |
| Close | With the Esc key or a click next to the window; there is no ✕ here. Nothing changes: When setting the primary source, no source is created, and before the full preview and the PDF no document is created, without a further message. | – |
Below the view it says, depending on the situation, “loading…”, “No records found.” or, in red, “The records could not be loaded with this view. Choose a different view above.” (without a list of views: “The records could not be loaded.”). The window shows at most 50 records. If there are more, it says below “There are more than 50 hits — the first 50 are shown. Search more precisely if your record is not among them.”
When the sample record is missing or cannot be read
The designer fetches the sample record from Dynamics anew every time the sample data is loaded. It distinguishes two cases:
| Case | What you see | What happens |
|---|---|---|
| The record was deleted in Dynamics. | In the list of sources, in red “⚠ Record missing”, on the right in the header “⚠ no longer exists in Dynamics”. In the template settings, after the name it says “— no longer exists in Dynamics” and below it in red “This record was deleted in Dynamics or can no longer be read. The canvas therefore shows no sample values — please choose another one.” | The full preview and the PDF ask for another record before every call. Choose another record. If you only take the old one out with “Remove”, the designer still asks for one before every full preview and every PDF; “Continue without a sample record” then delivers a document with empty fields instead of an error message. If the deleted record stays saved, “Continue without a sample record”, by contrast, creates no document: The error message says in English that the record was not found (see Full preview and PDF: Without a sample record). |
| Dynamics did not deliver it just now, for example because you lack the read permission or the fetch failed. | “⚠ could not be read (no read permission)” or “(fetch failed)”, once the message “⚠ The sample record »…« could not be read …”, in the template settings in red “Dynamics did not deliver this record just now (…) — it was NOT deleted. …” | The record stays saved. The full preview and the PDF do not ask for another one but create the document with it. If you lack the read permission, the document is then aborted with an English message that begins with “NO ACCESS” (see Rights and roles: When a right is missing). The next time the sample data is loaded, for example when you reopen the template, the designer tries again. |
The notes say that the canvas shows no sample values. Fields appear on the canvas as markers with their name anyway; what is affected is what the canvas calculates in the background with the sample data, such as images from data fields.
Additional sources
An additional source brings in a whole table from Dynamics that is not connected to the record being printed: for example the currencies, the bank details of your company or a table of text modules. Unlike the primary source, an additional source is always a list, never a single record. For connected records, such as the customer of a quote, you do not need an additional source; you reach them through relationships.
- Open “Manage data sources” and click “Additional source” on the left below the sources.
- In the “Choose a table” window, find the table and click it. The designer does not ask for a sample record here. First it asks in the “Additional data source without a condition” window whether it should load sample rows (see below). Then it reports “Source »…« added.”; the source is in the list on the left and in the data tree.
- Click “✓ Confirm” and save the template.
The designer does not check whether the same table is already there as a source. Create each table only once as an additional source.
The question “Additional data source without a condition”
Before the canvas fetches rows of an additional source without a rule, it asks: when creating it, when opening the template and when it rebuilds the sample data, but only once per table until you reload the page. The window explains: A rule can shorten the result with a filter or with “The first N”; this cannot reduce what is loaded, because for the printed document an additional source is always loaded in full (see What the canvas loads and what is printed).
| Button | What it does |
|---|---|
| “Load preview” | Fetches at most 50 rows for the canvas, in the same order as printing. If there are more, the designer reports once “Preview: of »…« the canvas shows at most 50 rows. All are printed — up to the upper limit that the document reports when it is reached.”. If loading fails, it reports “⚠ The preview of the source »…« failed — the canvas shows no rows there, the printed document does. …” |
| “Don't load”; likewise the Esc key and a click next to the window | The preview of this source stays empty on the canvas until you reload the page or attach a rule to the source. After reloading, the designer asks again; with a rule, the preview comes the next time the sample data is loaded. The source is printed anyway. The designer reports “Preview: »…« is not loaded because of your answer — …”. |
If a rule is attached to the source, the canvas does not ask. The preview then comes the next time the sample data is loaded, for example when you choose another sample record.
Getting values from an additional source
- A particular record: In the data tree, click “ƒ” on the header of the source and create a rule. Filter in it, for example “Code is EUR”, and in the “Selection” tab check “Keep only specific records”; “Only the first” is then preselected (see Rules). You then drag the fields of this rule into the template like any other field.
- As a table: Drag a rule on the source onto the page, or take it as the row source of a data table (see Data tables: The row source). The source itself is not available for choosing there.
- Sum, count and the like: In conditions, the fields of an additional source offer sum, count and the like over all their rows (see Conditions: Sum, count and so on over a list).
Caution
Fields directly under the source carry the suffix “first value” in the data tree (see Data tree and field picker: What the badges and suffixes mean). If you drag one into a text, the value from the first row of the unfiltered list is printed, sorted by the internal identifier, so not a particular record. You get a particular record only through a rule as described above.
- Lists (1:N) under an additional source cannot be dragged onto the page: They belong to each individual row of the source. A table on the source always sits on a rule on the source itself.
- An additional source is always loaded in full when printing, even if a rule filters it; use tables with a manageable number of records for this (see What the canvas loads and what is printed).
Removing an additional source
The red “✕” in its row (“Remove this data source”) asks for confirmation: “Really delete the source »…«? Its rules go with it. Tables and fields that point to this source or its rules stay empty afterwards.” With “Delete” the source disappears together with its rules, and the sample data is rebuilt (“Removing data source...”); “Cancel” leaves it. Like every change in the window, this applies only with “✓ Confirm”; “Discard” brings the source back. The primary source cannot be removed.
Caution
A table on the removed source or on one of its rules then prints only its header row; the feedback on the document reports this as a warning (see Problems and messages: Notes and warnings). Fields from it, by contrast, stay empty without any message. Therefore first remove the tables and fields that use the source.
Relationships
Under each source in the data tree are its fields and its relationships to other tables. You do not have to create relationships; the designer fetches them from Dynamics itself. There are two kinds:
| Badge | What it is | Example |
|---|---|---|
| “N:1” (blue) | A lookup to exactly one record. You insert its fields like the source’s own. | from the quote to the currency, the customer or the owner |
| “1:N” (violet) | A list of records. A data table is made from it. You show sums and counts as a one-row table on a rule (see Rules) or with a custom variable (see Variables). | from the quote to its items |
- The name of a relationship gives first the table it leads to, after it the field that connects the two, such as “Angebotsposition · Angebot”. That way you can also tell several relationships to the same table apart. The search also finds a relationship by its internal name.
- A relationship loads its fields only when you expand it (see Data tree and field picker: Expanding, loading, depth).
- Relationships can be expanded one after another, for example from the quote to the item and on to the product. Printing goes down to the sixth level; the data tree offers nothing deeper.
- A lookup field such as “Currency” appears in the data tree as “Currency (Name)” with the badge “Abc”: It prints the name of the record it points to. Next to it is “Currency (ID)” with the internal identifier of this record. For all other fields of the record, expand the relationship of the same name. For some lookups Dynamics keeps no name, such as “Owner (User)” and “Owner (Team)”. There only “… (ID)” appears; you insert the name from the relationship of the same name.
- Relationships with many records on both sides (N:N) are not offered by the designer.
- A new data table always sits on a rule. If you drag a list onto the page, the designer therefore first creates a rule (see Data tree and field picker: Clicking and dragging).
- A relationship costs no query of its own when printing; more on this under How the document fetches the data.
The data tree itself has a page of its own: structure, search, expanding and dragging, the badges and suffixes and the field picker in conditions are described under Data tree and field picker.
The “Assign variables” window
Fields in an inserted excerpt still point to where they come from. The “Assign variables” window asks you once what they should point to here. “Variables” here means all fields and custom variables in the excerpt. The window writes nothing into the template until you apply.
- 1Names the reason: where the excerpt comes from and that anything left open is removed from the text when you apply.
- 2Green: The internal name and the type match. The designer found the target itself.
- 3Gray: Nothing was found. The place is removed from the text when you apply.
- 4Yellow: The name matches, the type could not be confirmed. Only a click on ✓ counts as done.
- 5A table needs a row source. Without one it stays with its header row and design but empty; the label “stays empty” shows this.
- 6On the left “Remove variables”, in the middle the counting line, on the right “Cancel” and “Apply”.
When it appears
| Occasion | Title of the window |
|---|---|
| You paste an excerpt from another template with Ctrl+V, also several objects at once or in the group designer. | “Assign variables” |
| You set the primary source of a template that already has content. Its custom variables are checked too. | “Assign variables” |
| You paste an excerpt into another table row of the same template. | “Variables are leaving their row” |
| In the “Edit text” window you paste copied text into another row. Here the designer asks before it pastes. | “Variables are leaving their row” |
| All the fields match, but the excerpt uses custom variables that do not exist in this template. | “Custom variables are missing here” |
| In the properties of a data table you change the row source and keep the columns (see Data tables: Changing the row source). | “Assign the columns to the new row source” |
The window appears only if, after the designer’s suggestions, something is left open. Otherwise it reports “The variable fits here — nothing to assign.”, “All … variables fit here — nothing to assign.” or “The columns match the new row source — nothing to assign.”; in the “Edit text” window the text is then pasted without a message.
What is in the window
- At the top a sentence that names the reason, such as “The inserted excerpt comes from »…« and still points to the fields from there. …”, with an ⓘ. If you pasted into a table row, it is followed by “Pasted into: »…« — this row is fixed and is not asked about.”
- The box “Custom variables that do not exist in this template”, if the excerpt uses such variables. It explains: “Custom variables belong to the TEMPLATE, not to the data source …”. For each @variable you choose in a selection list. Preselected is “take along — create here (…)” with its type. If its definition did not come along, “take along — create empty (the definition was not copied)” appears there instead. In addition, for each custom variable of this template there are “point to »@…«” and “nothing — remove from the text when applying”.
- “Document” with the gray note “Fields without a table”: the fields outside tables.
- One indented header per table with its name and “Rows from:”. The button next to it shows the chosen row source or “— choose —” and opens the “Row source for »…«” window. A table in a table cell shows “— outer table first —”; it can be assigned only once the outer one is fixed. Without a row source it says below it “Without a row source this table stays empty — including the fields below it.”
- One row per field: badge (or “?” if the type is unknown at the origin), the field name and after it a button with the chosen target or “— choose —”. It opens the “Field for »…«” window and is disabled as long as the table lacks its row source. A field that appears in several places is only one row and one decision; when you point at the name with the mouse, you see in how many places it occurs. If you choose a field of another type, the designer warns: “»…« is …, the original field was …. Assigned — please check the result.”
On the right in each row a label shows what happens when you apply:
| Label | Meaning |
|---|---|
| “fixed” (blue) | The row you pasted into. It is the location, not an assignment, and is not asked about. |
| “assigned” (green) | The internal name and the type match, or you chose or confirmed the target yourself. |
| “check” (yellow) with “✓” | The name matches, the type could not be confirmed. This does not count as done: A click on “✓” confirms the suggestion, otherwise the place is removed when you apply. |
| “will be removed” (gray) | Nothing was found. The place is removed from the text when you apply. |
| “stays empty” (gray, on a table) | The table has no row source. It stays with its header row and design, only without data rows. |
At the bottom a line adds up, for example “3 assigned · 2 will be removed (1 of them unchecked) · 1 table without rows”; for custom variables it is preceded by how many are taken along, re-pointed or removed.
The “Row source for …” and “Field for …” windows
Both windows show the familiar data tree (see Data tree and field picker: What is in the tree), but without custom variables and system variables; nothing can be dragged in them. If you close them with ✕, the Esc key or a click next to them, nothing changes.
- Row source: As in the “Choose the row source of the table” window, the tree shows only relationships and rules, has the same search box and, on lists (1:N) and rules, the small button “choose” (see Data tables: The “Choose the row source of the table” window). Here the current choice is also highlighted, and under an additional source the button exists only on the rules of the source itself. A rule can be used immediately. If you choose a list, the designer creates a rule for it and opens “Edit rule”; if you cancel there, nothing is left behind. The rule costs a query of its own only if its filter already takes effect when loading; the explanatory text in the window says this too (see How the document fetches the data). A lookup (N:1) is not available for choosing, but you can go on through it. If the table is in a table cell, the lists offered apply within a row of the outer table.
- Rule with a single selection: If a rule has the selection “Only the first”, “Only the last” or “The one at a specific position”, the designer warns before the choice, as for a data table, in the “This rule returns only one record” window (“Cancel” / “Use it anyway”): As a row source, the table prints no row in the PDF, but the canvas still shows the sample row (the reason is described under Rules: Keeping specific records).
- Field: The tree shows the fields, with the search box “🔍 Search fields & relationships…”. In a table the fields apply within one of its rows, and the tree is structured as in the “Choose a field of this row” window (see Data tree and field picker: The “Choose a field of this row” window). On the right, on fields under a list, you choose what becomes of them, as in conditions (see Conditions: Sum, count and so on over a list).
- Below the tree a button clears the choice: “— no row source —” (the table stays without data rows) or “— assign no field —” (the place is removed when you apply).
Applying, removing or canceling
| Button | What it does |
|---|---|
| “Assign all” or “Apply” | Blue, on the right. It is called “Assign all” if nothing is removed, every table has a row source and the excerpt brings no custom variables that do not exist here; otherwise “Apply”. Enters all confirmed assignments. What is open and unchecked is removed from the texts, a table without a row source stays without data rows. If there are unchecked suggestions, the designer first asks in the “Unchecked suggestions” window with their list (“Back” / “Apply anyway”). |
| “Remove variables” | Red, on the left. Removes all variables from the texts and detaches the tables from their row source, after a confirmation question that counts the places concerned (“Cancel” / “Remove”). A table does not become empty as a result, but prints one row that is bound to the main record; you set the row source anew by hand afterwards. Page number, date, user and formulas in the text stay. Conditions, sort orders and the origin of images also stay and then point to nothing; the designer names them. |
| “Cancel” or “Insert unchanged”, Esc key, click next to the window | Leaves everything as it is; the fields keep pointing to their origin. The designer reports, for example, “Nothing assigned — the pasted content still points to the old fields.”. In the “Edit text” window the button is called “Insert unchanged”: The text is pasted with the old variables (“Inserted unchanged — the variables still point to the old row.”). |
After “Apply” or “Remove variables”, the “What happened” window shows what was entered, removed and left standing, with a number per group: “Zugeordnet”, “Zeilenquellen”, “Neue Regeln”, “Bildherkunft mitgezogen”, “Gleich geblieben”, “Aus den Texten entfernt”, “Tabellen ohne Zeilenquelle”, “⚠ Bleibt stehen und zeigt ins Leere” and “⚠ Nicht zugeordnet”. Only groups with content appear; when you point at a row with the mouse, you see the exact path. “Got it”, the Esc key or a click next to it close the window. If there was nothing to do, the designer only reports “Nothing to do — there were no data references.”
Caution
What is under “⚠ Bleibt stehen und zeigt ins Leere” you check yourself: A condition whose field is missing, depending on how it is worded, never or always applies, and such a filter may let all rows through. Replace the field there by hand.
What the canvas loads and what is printed
To keep the designer fluid, the canvas loads only an excerpt of the data. The document loads everything it needs for printing as soon as it is created for a real record. Without a sample record, the full preview and the PDF from the designer show only what the canvas has loaded (see Full preview and PDF: Without a sample record).
| Canvas | Full preview and PDF | |
|---|---|---|
| Primary source | the sample record | from the designer the sample record; through a button or flow the record being printed |
| Lookup (N:1), such as the opportunity of a quote | the linked record of the sample record, as soon as the template uses one of its fields (in a condition, a custom variable, an image, the currency) or you expand the relationship in the data tree; only with a sample record | always the linked record |
| List (1:N), such as the items | at most 20 rows, only with a sample record | all rows; a filter in the rule of the list can already shorten loading if nothing else needs the whole list |
| Additional source | at most 50 rows, without a rule only after a question | the whole table is loaded, even if a rule filters; the rule only afterwards shortens what is printed |
| Relationships one after another | down to the sixth level | down to the sixth level |
If a list has more rows than the canvas loads, the canvas says so once (see Data tree and field picker: Expanding, loading, depth). Where the canvas calculates with sample data, such as in rules, sums, “The first N” and conditions and in the preview in the window of a variable, it then calculates only with these rows. The correct numbers are shown by the full preview and the PDF.
Other limits: The table choice shows at most 50 hits, the choice of the sample record at most 50 records with at most eight columns.
Good to know
The document also has an upper limit that should not come into play in everyday use: 20,000 rows per query and 90 seconds for loading. If one of them is reached, loading stops there, and the feedback on the document reports it as a warning (see Problems and messages: Notes and warnings). Sums and counts over this list are then not correct. For a list such as the items, a filter in its rule that already takes effect when loading helps, for example “Quantity greater than 0”; not every filter takes effect when loading (see Rules). This helps only as long as nothing else needs the whole list, such as a sum over all items in a text (see How the document fetches the data). For an additional source no filter helps, because it is always loaded in full; there only a table with fewer records helps.
How the document fetches the data
When printing, the document fetches the data in queries to Dynamics. You usually do not notice this; but it explains why relationships cost nothing and additional sources do:
- Queries arise per source and per rule on a list whose filter already takes effect when loading (see Rules), at most one per rule. Every other rule, including every rule directly on a source, calculates over rows that are loaded anyway and costs no query of its own. The document loads the whole list only if something needs it unfiltered: the template itself, such as a sum over all items in a text, a rule without such a filter or a rule outside the list, such as on the invoice, that calculates over all rows of the list. If only rules with such a filter need the list, each of them fetches only its own rows. A rule that nothing in the template points to is not calculated by the document at all.
- A relationship costs no query of its own: Connected records, lookups as well as lists, are fetched by the document in the same query.
- A further query otherwise begins only if a query would become too large or hit a limit of Dynamics: with more than four lists in a row, such as quote › items › batches › …; as soon as two lists side by side would come into the same query, such as the items and the contacts of the customer, because together they would produce every combination of the two lists; and with more than ten links in a query.
- The document never asks for each record individually.
- How many queries there are in the end also depends on the data.
What changes in the document?
On the canvas
Fields appear as a blue marker with their name, not with their value, and data tables show a sample row. The sample record still has an indirect effect: Images from data fields show its image, and for texts with versions and for image rules, what is seen depends on its values. Sources, relationships and rules themselves you see only in the data tree.
In the PDF
Each field shows the value of the record being printed for, from the designer that of the sample record. Each data table shows all rows of its rule, and additional sources are loaded in full.