Inserting Data
This page shows how to print single values from the quote data: a customer name, a selected robot, a request field or a BoM total. To repeat content for every product, see Repeating Content.
Simple values
Write d. followed by the name of the field:
Dear {d.name},Thank you for your interest. Please find quote {d.id} below.Dear Jane Doe,Thank you for your interest. Please find quote 2586 below.Nested values
Use a dot to go one level deeper:
Your contact: {d.user.name} ({d.user.email})Your contact: Alex Seller (alex@yourcompany.com)Items in a list
Lists are numbered from zero. [0] is the first item, [1] the second, and so on.
{d.form_submissions[0].form.name}{d.form_submissions[0].form.data.elements[1].label}{d.form_submissions[0].form.bom.tables[0].label}Migatronic CoWelder V2RobotCoWelder QuoteTo get the last item of a list, use [i=-1]. [i=-2] returns the second to last:
Last element in the form: {d.form_submissions[0].form.data.elements[i=-1].label}Last element in the form: Quote SpecificationSearching a list
Positions change when you edit a form or BoM, so it’s usually better to search for an item by one of its fields. Write the condition in square brackets:
Robot: {d.form_submissions[0].form.data.elements[label='Robot'].options[0].label}Warranty: {d.extra_fields[name='Commercial Terms'].fields[slug='warranty'].value}Discounts table: {d.form_submissions[0].form.bom.tables[label='Discounts'].label}Robot: UR12eWarranty:Discounts table: DiscountsRules for searching:
- Put text in single quotes:
[label='Robot']. Quotes are required when the text contains spaces, and recommended always. - Numbers don’t need quotes:
[id=51824]. - You can use
=,!=,>,<,>=and<=. - Combine several conditions with a comma. All of them must match:
[groupLabel='Software', type='element-without-options']. - You can search inside nested fields:
[productProperties.type='Robot']. - If more than one item matches, the first match is used.
More examples with the example quote:
| Goal | Tag | Result |
|---|---|---|
| Selected power source | {d.form_submissions[0].form.data.elements[groupLabel='PowerSource', type='element-with-options'].options[0].label} | MIG |
| First option that is a robot product | {d.form_submissions[0].form.data.elements[label='Robot'].options[productProperties.type='Robot'].label} | UR12e |
| Software discount entered | {d.form_submissions[0].form.data.elements[label='Software discount in %'].value} | 50 |
| Price of the delivery line | {d.form_submissions[0].form.data.elements[label='Delivery'].options[0].price} | 3761 |
| Total discount from the BoM | {d.form_submissions[0].form.bom.tables[label='Discounts'].groups[0].rows[type='subtotal'].subtotals[field='sales_price'].value} | -78,290.00 kr |
| Grand total from the BoM | {d.form_submissions[0].form.bom.summary.rows[0].value} | 516,551.00 kr |
Product properties
Product properties are stored as name/value pairs in productProperties. Read them like any other field:
Type: {d.form_submissions[0].form.data.elements[label='Robot'].options[0].productProperties.type}Solution: {d.form_submissions[0].form.data.elements[label='Robot'].options[0].productProperties.solution}Type: RobotSolution: MotionPlusTo list all properties of a product, see Looping over product properties.
Going up a level
Two dots .. go back up one level in the data. This is handy after a search, when you found an item and want a field from its parent:
{d.form_submissions[0].form.data.elements[label='Robot'].options[0]..groupLabel}SolutionShortcuts (aliases)
Paths into a configuration can get long. An alias gives a path a short name. Declare it once, anywhere in the template (the declaration is removed from the output), and use it with $:
{#config = d.form_submissions[0]}{#elements = d.form_submissions[0].form.data.elements}{#bom = d.form_submissions[0].form.bom}{#terms = d.extra_fields[name='Commercial Terms']}
Configurator: {$config.form.name}Robot: {$elements[label='Robot'].options[0].label}Total: {$bom.summary.rows[0].value}Payment terms: {$terms.fields[slug='payment'].value}Aliases with parameters
An alias can take a parameter, which makes it work like a small function. This is useful when you print many elements in the same way:
{#selected($label) = d.form_submissions[0].form.data.elements[label=$label].options[0]}
Robot: {$selected('Robot').label}Welding: {$selected('Welding method').label}Training: {$selected('Training').label}Robot: UR12eWelding: MIGTraining: Basic Training PackageEmpty values
When a field is empty or doesn’t exist, the tag prints nothing. To print a fallback, use a condition:
Warranty: {d.extra_fields[name='Commercial Terms'].fields[slug='warranty'].value:ifEM():show('To be agreed')}Warranty: To be agreedIf the value is not empty, it is printed as normal. See Conditions for more.
Current date
{c.now} contains the date and time at which the document is generated:
Printed on {c.now:formatD('DD-MM-YYYY HH:mm')}Common mistakes
| Wrong | Right | Why |
|---|---|---|
{{d.name}} | {d.name} | Tags use single braces. |
{d.form_submissions.form.name} | {d.form_submissions[0].form.name} | form_submissions is a list. Pick an item first. |
{d.elements[0]options[0].label} | {d.elements[0].options[0].label} | A dot is required after ]. |
{d.elements[label="Robot"]} | {d.elements[label='Robot']} | Only single quotes are allowed. |
{d.first name} | {d.firstName} | Field names can’t contain spaces. |