How do I create a Word file as an export template and which commands can I use for the export?
Learn how to set up a Word file as an export template, which commands you can use for fields, photos, sketches, signatures, lists and checkboxes, and how to add conditions and formatting.
Vaira web training – export templates
In this video (in German), Dennis from our marketing team shows you how to
- find the information you need for your export template in Vaira Office,
- create an export template in Microsoft Word and use formatting,
- upload the export template to Vaira,
- download the export template with the data filled in automatically,
- and what more complex export templates can look like.
Before you start
This article is a detailed guide that explains export templates, how they are structured and all commands in detail. If you're already familiar with them or you're an IT professional who just needs a cheat sheet without much background, we've prepared something for you too: Export template commands – cheat sheet.
This article shows you where to upload your export template to Vaira once it's ready: How can I upload an export template for a workflow?
What is an export template?
Vaira lets you export job data directly to a PDF. To do this, you store a Word file in the corresponding workflow . You upload it in Vaira Office in the respective workflow under “Export templates” in the left navigation. The Word file can be, for example, your company's own report template. It needs to be set up so that the values and data you want from Vaira can flow into the export template .
This documentation shows examples of how to set this up. Important for the commands: the identifier fieldID is your field ID in Vaira, and the taskID is your task IDin Vaira.
Where can I create my export template or add it to a workflow?
You'll find a detailed guide here: How can I upload an export template for a workflow?
How do I export values from Vaira to my export template?
As you know, your workflow is made up of steps that are connected to each other and together map your process. Each step consists of any number of tasks. Tasks can contain any number of their own fields . This structure is also the basis for your export.
In your export template, all you have to do is write certain commands in the right places – Vaira takes care of the rest automatically when you export. The best part: you can carry your existing Word documents over to the digital world one-to-one. Instead of leaving the fields blank, printing the file, having someone fill it in by hand and then typing everything up again afterwards, you simply write the commands into the document and upload it to Vaira. This could look like this, for example:
Here you can see a typical form with the matching commands in its fields. We list the commands for you further down. When you export, Vaira goes through this template once, replaces all commands with the matching values from your process and gives you the result as a clean PDF. After the export, it could look like this, for example:
The fields keep the formatting you used when you entered the commands. Font size, whether values are bold or italic , whether they're left-aligned or centered: Vaira carries all of this over to your export. And if a field hasn't been filled in (yet) at the time of export, that's no problem either: the field simply stays empty in the export.
Depending on the field type, the syntax for the export can differ slightly. Below you'll find the right syntax for each field type.
Overview and quick navigation
- Syntax for standard data exports
- Photos from photo fields
- Sketches from surveys
- Photos from surveys
- Signatures
- Lists
- Checkboxes
-
-
Syntax for conditions
- Syntax for formatting
The syntax for standard data exports
In the following commands, you only need to adjust the values in bold . Don't change anything else – that's the only way Vaira can work with the commands. So please make sure you always use the right type of bracket and keep every quotation mark and every comma.
{% raw %}
Text, number, date, timestamp, user and selection fields
All of these field types use the same call:
{# field("taskID/fieldID") #}
Apart from the basic structure, all you need to do is replace taskID and fieldID with the matching values. The taskID is the ID you gave your task. The fieldID is the ID of your field. In the example from the image above, for the field Zahl 1 you would therefore write the following at the right place in your Word template:
{# field("SummeBerechnen/zahlEins") #}
Good to know: Date fields end up in the export in the format DD.MM.YYYY, timestamps as DD.MM.YYYY hh:mm:ss with time zone (German time). Vaira outputs numbers with a period as the decimal separator, for example 12.5. To learn how to get a comma instead, see the section on decimal places below.
Single photos from photo fields
Here you work with a simple loop. The advantage: if there are no photos, the export still works. And with these three lines of code, Vaira exports all photos in that field for you. The code looks like this:
{# FOR img IN field("taskID/fieldID") #}
{# IMAGE getImage($img, width,height) #}
{# END-FOR img #}
As usual, you enter the taskID and the fieldID . Then you enter the width (e.g. 5) and/or the height (e.g. 3). The dimensions refer to centimeters in your export.
Important: If you specify width and height at the same time , the image is stretched or squashed to fit those dimensions. In other words, the aspect ratio of width to height is forcibly changed. If you specify only the width or only the height , that value applies and the other value is adjusted to match the aspect ratio. If you don't want to specify a value, simply write undefined in its place, for example: ($img,undefined,5). Without width and height, the photo will be 6 × 6 cm.
To give you a better idea of what this looks like, here are some examples: at the top the command with different values, below it the result – the first and last lines of the loop are left out here for clarity:
{# IMAGE getImage($img, undefined,3) #}
{# IMAGE getImage($img, 4,undefined) #}
{# IMAGE getImage($img, 2.5,3.2) #}
As you can see in the last example, you can also enter decimal values. However, since the comma is a separator within the command, you have to use a period instead of a comma in your number: so write 2.5, not 2,5.
Multiple photos from photo fields as a gallery
The command for exporting photos as an image gallery (that is, several photos side by side and one below the other) consists of two parts: a general call and a few commands in a prepared table. Neither of them appears in the export – both are replaced by the image gallery.
To export photos as a gallery, you first need a command directly before (or above) your table. Insert the following code there in your Word template:
{# EXEC
const imagesPerRow = 3;
var images = field("taskID/fieldID");
gallery = [];
while (images.length > 0) {
gallery.push(images.slice(0, imagesPerRow));
images = images.slice(imagesPerRow);
}
#}
Replace the value for taskID with the ID of the task as usual, and the fieldID with the ID of the field that contains your photos.
This code tells Vaira how to handle the table that follows. It specifies that you want to fill a table with three columns and that all photos should be exported into it.
Now comes the table. Create it with three columns and three rows. With every individual export, the code makes sure that Vaira creates exactly as many rows as are actually needed.
|
{# FOR row IN gallery #} |
|
|
|
{# $row[0].featureId #} {# IMAGE getImage($row[0], 5.5) #} |
{# IF $row.length > 1 #} {# $row[1].featureId #} {# IMAGE getImage($row[1], 5.5) #} {# END-IF #} |
{# IF $row.length > 2 #} {# $row[2].featureId #} {# IMAGE getImage($row[2], 5.5) #} {# END-IF #} |
|
{# END-FOR row #} |
|
|
Good to know: The code snippets {# $row[0].featureId #}, {# $row[1].featureId #} and {# $row[2].featureId #} are optional. They output the point number of a photo. Point numbers only exist for photos from surveys; for photos from photo fields, they stay empty. So you can also leave them out here.
You don't need to change anything in this code. The result of your export in the PDF could then look like this, for example:
All sketches from a survey field
You get all sketches from a survey field with the following command:
{# FOR measurement IN field("taskID/fieldID") #}
{# IMAGE getImage($measurement.sketch,width,height) #}
{# END-FOR measurement #}
The structure is very similar to an image export. Here, too, we use a loop so you don't get an error if there is no sketch to export. At the same time, these three lines let Vaira export all surveys one after the other if several surveys were created in the field. Here, too, you first have to enter the taskID and the fieldID to tell Vaira which field in which task you mean. You also need to specify the width and/or the height of your exported sketch in centimeters.
Important: If you specify width and height at the same time, the sketch is drawn in exactly that format. It isn't distorted – instead, the visible section adjusts. If you specify only the width or only the height, that value applies and the other results from the aspect ratio. Write a value you don't want to specify as undefined, e.g.: ($measurement.sketch,undefined,5). Without width and height, the sketch will be 6 × 6 cm.
You can also add one or both of the following commands to the loop. They let you export the display name
{# $measurement.sketch.displayName #}
and the description of each sketch.
{# $measurement.sketch.description #}
If you want to export both, your final export command will look like this:
{# FOR measurement IN field("taskID/fieldID") #}
{# IMAGE getImage($measurement.sketch,width,height) #}
{# $measurement.sketch.displayName #}
{# $measurement.sketch.description #}
{# END-FOR measurement #}
You don't need to change anything in the two optional commands.
The look and content of your sketches
You can customize your sketch even further. To do this, add curly brackets {...} after the general call, with the individual commands separated by commas {..., ..., ...} . The available parameters are:
withMarkers: trueorwithMarkers: false- “Markers” are the thick, colored dots in the sketch at the places where a survey point was recorded. These dots are only shown if you choose the value true here; otherwise your survey line may have clearly visible bends but no feature points. If you don't specify anything, it depends on how you export: with Download the markers are shown, with Download without Feature-IDs they aren't.
withSymbols: trueorwithSymbols: false- “Symbols” are the symbols you have assigned either to components or to individual survey points. They are printed at the corresponding place in the sketch if you choose
truehere.
- “Symbols” are the symbols you have assigned either to components or to individual survey points. They are printed at the corresponding place in the sketch if you choose
Tip: To keep the sketch from getting too cluttered, it can make sense to show only symbols (withSymbols: true and withMarkers: false) or only markers (withSymbols: false and withMarkers: true) . Showing both together can get confusing.
withDimensionLines: trueorwithDimensionLines: false- “DimensionLines” are the dimension lines of your sketch – that is, the values that are determined with dashed lines based on the orthogonal survey and the zero point and vanishing point. If you don't specify anything, the dimension lines are shown, even when you download without feature IDs.
withLengthsAndAreas: trueorwithLengthsAndAreas: false- “LengthsAndAreas” covers the lengths and area sizes shown directly on the survey lines – for example, the length from point A to point B of a pipeline in meters or the area of a surveyed trench in square meters. If you don't specify anything, it follows the value of withDimensionLines.
fullBackground: trueorfullBackground: false- “fullBackground” refers to the background map you may have added. If you choose
false, the section is chosen so that the survey is fully and optimally visible, and only the part of the background map visible in that section is shown. If you choosetrueinstead, the complete background map is printed and the sketch is scaled down accordingly so that the background image is fully visible.
- “fullBackground” refers to the background map you may have added. If you choose
mapBackground: "osm" places an OpenStreetMap map under your sketch as a background. The map section is based on your survey, and the sketch then shows the notice “© OpenStreetMap”. If you don't specify anything, there is no background map. The other values "tms" and "osm-tms" only work if they have been enabled for your organization. Otherwise, the export stops with an error message.
{# IMAGE getImage($measurement.sketch, 17.5, 19, {mapBackground: "osm"}) #}
rotation: 90 rotates an image clockwise by the specified number of degrees. This works not only for sketches but for all images, including photos. If you don't specify anything, Vaira automatically rotates photos the way they were taken. With rotation: 0 you turn this off. Good to know: Width and height always refer to the image after rotation.
Tip: In our experience, fullBackground: false is the usual approach so that the sketch is as easy to read as possible. That's why the default value here is false and you have to explicitly set it to true to export it differently.
An example of a complete sketch export command with all parameters could look like this:
{# IMAGE getImage($measurement.sketch,17.5, 19, {fullBackground: true, withMarkers: false, withSymbols: true, withLengthsAndAreas: false, withDimensionLines: true}) #}
In detail, this command means:
{# IMAGE getImage($measurement.sketch,is the general command to retrieve all sketches,17.5, 19,are the dimensions your sketch should have, as explained in more detail in the section All sketches from a survey field ,{fullBackground: true, withMarkers: false, withSymbols: true, withLengthsAndAreas: false, withDimensionLines: true}are the individual parameters in curly brackets, separated by commas, which make sure that
- with
fullBackground: truethe complete background is always visible, even if this makes the sketch smaller, - with
withMarkers: falsethe surveyed points are not highlighted with larger circles, - with
withSymbols: truethe component symbols are shown at the surveyed points, - with
withLengthsAndAreas: falsethe individual measured values on lines for the lengths of segments and the size of areas are not shown, - with
withDimensionLines: truethe orthogonal dimension lines with measured values are shown.
- with
Of course, you can set the parameters to true or false as you like and customize your sketch exports this way.
Exporting a single, specific sketch
Important: This function can lead to unexpected results and should only be used by experienced users. Since it outputs a specific sketch based on the order of the surveys, in most cases it's sufficient and advisable to follow the section All sketches from a survey field instead and output all sketches.
You get a specific sketch from a survey field with the following command:
{# IMAGE getImage(field("taskID/fieldID")[0].sketch,width,height) #}
Width and height are specified in cm. If you specify both, the sketch is drawn in exactly that format; with only one value, the aspect ratio is kept. Write a value you don't want to specify as undefined.
Optionally, you can also export both the display name of the survey
{# field("taskID/fieldID")[0].sketch.displayName #}
and the description of the survey
{# field("taskID/fieldID")[0].sketch.description #}
Photos from a survey field
This command is a bit more extensive, but here too you only have to make minor adjustments yourself. You can simply copy the rest again:
{# FOR measurement IN field("taskID/fieldID") #}
{# FOR img IN $measurement.images #}
{# $img.featureId #}
{# IMAGE getImage($img, width,height) #}
{# END-FOR img #}
{# END-FOR measurement #}
As usual, in the first line you use taskID and fieldID to specify which field from which task should be used. For once, the featureID is not an ID you have to enter. It simply tells Vaira to include the matching survey point number with each image. You only need to enter the width and/or the height yourself, just as you already know from image exports.
Paragraphs and spacing between photos
If you export several photos one below the other, you can add clean spacing within the loop in your Word template – just like with normal text:
-
Insert empty paragraphs: In your Word template, add an empty line (press Enter) between the image command and END-FOR. It's output with every repetition and creates space between the photos.
-
Use paragraph spacing in Word: In Word, set the paragraph spacing “After” for the line with the image command (Home › Paragraph). This way, every photo automatically gets the same spacing, without empty lines.
-
Example with an empty line in the loop:
{# FOR img IN field("taskID/fieldID") #}
{# IMAGE getImage($img, width, height) #}
← leave an empty line here in Word
{# END-FOR img #}
Multiple photos from survey fields as a gallery
The command for exporting photos from surveys as an image gallery (that is, several photos side by side and one below the other) consists of two parts: a general call and a few commands in a prepared table. Neither of them appears in the export – both are replaced by the image gallery.
To export survey photos as a gallery, you first need a command directly before (or above) your table. Insert the following code there in your Word template:
{# FOR measurement IN field(“taskID/fieldID”) #}
{# EXEC
const imagesPerRow = 3;
var images = $measurement.images;
gallery = [];
while (images.length > 0) {
gallery.push(images.slice(0, imagesPerRow));
images = images.slice(imagesPerRow);
}
#}
{# END-FOR measurement #}
Replace the value for taskID with the ID of the task as usual, and the fieldID with the ID of the survey field that contains your photos.
This code tells Vaira how to handle the table that follows. It specifies that you want to fill a table with three columns and that all photos should be exported into it.
Now comes the table. Create it with three columns and three rows. With every individual export, the code makes sure that Vaira creates exactly as many rows as are actually needed. Note: This works reliably if the field contains only one survey. If there are several surveys, only the photos of the last one appear.
|
{# FOR row IN gallery #} |
|
|
|
{# IMAGE getImage($row[0], 5.5) #} |
{# IF $row.length > 1 #} {# IMAGE getImage($row[1], 5.5) #} {# END-IF #} |
{# IF $row.length > 2 #} {# IMAGE getImage($row[2], 5.5) #} {# END-IF #} |
|
{# END-FOR row #} |
|
|
You don't need to change anything in this code. The result of your export in the PDF could then look like this, for example:
Signature from a signature step
If your workflow has a step of the type Signature, you can output the signature, name, place and date of each party in your export template. This way, your report is already signed when you export it. To learn how to collect signatures in Vaira Office and in the Vaira App, see the guide How can I collect signatures in Vaira Office and in the Vaira App?
For this, you need the ID of the step (stepID) and the ID of the party (partyID) as they appear in the workflow. You output the drawn signature like this – the number at the end is the width in centimeters:
{# IMAGE getImage(steps.stepID.signatures.partyID, 6) #}
You get the name, place and date of the signature like this:
{# steps.stepID.signatures.partyID.signer #}
{# steps.stepID.signatures.partyID.place #}
{# steps.stepID.signatures.partyID.date #}
Example: If your step is called acceptance and the party customer, the command for the drawn signature is {# IMAGE getImage(steps.acceptance.signatures.customer, 6) #}.
Tip: If the step has several parties, you output all of them in a loop: {# FOR p IN steps.stepID.signers #} … {# END-FOR p #}. Within the loop, you use {# IMAGE getImage($p, 6) #} for the signature as well as $p.displayName (name of the party), $p.signer, $p.place and $p.date. Signatures that haven't been given yet appear as an empty field of the same size, so your document has the same layout before and after signing.
Good to know: You can also access a signature with the command signature. It works like field, just with the ID of the step and the ID of the party:
{# signature("stepID/partyID").signer #}
{# IMAGE getImage(signature("stepID/partyID"), 6) #}
In addition to signer, place and date, the following information is available: displayName (name of the party, set even without a signature), signed (true as soon as it has been signed), createTime (time at which the signature was saved) and stale (true if the signed values have changed since then). With signed you can, for example, output a text only once it has been signed:
{# IF signature("acceptance/customer").signed #}Accepted on {# signature("acceptance/customer").date #}{# END-IF #}
Values from lists
While a process is being worked on, lists can be created. Lists consist of any number of individual objects (for example components or service items), which in turn have properties. The properties of the objects have their own ID so that Vaira can address them; below, it's called AttributeID.
To export lists, you first need a command directly before (or above) your table. Insert the following code there in your Word template:
{# EXEC
def = (val) => val ? val: 1;
#}
You don't need to adjust anything here. Next comes the table. The example shows a simplified component table consisting of the object's name (“Material”) and three attributes: unit, quantity and item number. The function def outputs 1 if a value is empty or 0 – handy for quantities.
| Material | Unit | Quantity | Item number |
With the code you need, the table then looks like this:
| Material | Unit | Quantity | Item number |
|
{# FOR item IN field("taskID/fieldID") #} |
|
|
|
|
{# $item.asset #} |
{# $item.values.attributeID #} |
{# def($item.values.attributeID) #} |
{# $item.values.attributeID #} |
|
{# END-FOR item #} |
You can simply write each piece of code in one go – the line breaks here only appear because the table is too narrow.
As you can see, we start with a row at the beginning and at the end in which only the first cell contains something. These are essentially the “start” and “stop” commands. Here you tell Vaira to extend the list by as many rows as there are objects in the list. In other words, you don't have to prepare 200 rows for your list. These three cells are enough, and Vaira makes the exported list exactly as long as it needs to be.
In the first row after the header row, you again use taskID and fieldID as usual to specify which list from which task should be exported.
In the single row, you then specify the format, i.e. which attributes the objects should be exported with. You don't need to adjust the command in the leftmost cell at all – Vaira simply lists all objects for you.
Each attribute column initially has the same command. Here you only need to insert the attributeID . For unit, this could be the ID “unit”, for example – depending on what you defined in Vaira.
Filled in by you, the table could then look like this, for example:
| Material | Unit | Quantity | Item number |
|
{# FOR item IN field("docs/componentlist") #} |
|
|
|
|
{# $item.asset #} |
{# $item.values.unit #} |
{# def($item.values.quantity) #} |
{# $item.values.itemNo #} |
|
{# END-FOR item #} |
The first and last rows aren't exported. Instead, the export shows just the list of objects in your list. In our example, it could look like this:
| Material | Unit | Quantity | Item number |
| PE coupler | pcs | 4 | 123 |
| PE pipe | pcs | 5 | 332 |
| Gas excess flow valve | pcs | 1 | 345 |
| Adhesive tape | m | 5 | 654 |
| Expanding foam | can | 1 | 678 |
| Paving stone | pcs | 1 | 827 |
Objects from lists within surveys
In your surveys, you can add objects to your survey points – a typical example are components or service items that you want to locate on individual parts of the survey. To do this, you first define the survey in the code from which the objects should be retrieved.
Then, in the first column of your table, you add code that creates as many rows as there are objects in the survey. In the other columns, you then specify which fields of the objects each piece of information should be taken from. In practice, this looks like this, for example:
{# FOR measurement IN field(“taskID/fieldID”) #}
| Point number | Name | Length | Width |
|
{# FOR item IN $measurement.items #} |
|
|
|
|
{# $item.featureId #} |
{# $item.asset #} |
{# $item.values.length #} |
{# $item.values.width #} |
|
{# END-FOR item #} |
{# END-FOR measurement #}
The values in bold are again the ones you have to adjust for your individual case. Above the table, enter the identifier of the task for taskID and for fieldID the identifier of the specific survey field you want the table to refer to.
You don't need to adjust any values in the first column. In the other columns, you specify the ID of the object property you want – that is, the ID of the field. The result could then look like this, for example:
| Point number | Name | Serial number | Material |
|
1.1 |
House connection entry |
VG-H1004-DE-240709 |
PE100 |
|
1.2 |
Excess flow valve |
BK-DA2-0711-A32 |
PE100 |
| 1.3 | Coupler | GRB-PVC80-RH-0105 | PE100 |
|
1.4 |
Coupler |
GRB-PVC80-RH-0122 |
PE100 |
|
1.5 |
Main line branch |
NET-KM230-BN-000189 |
PE100 |
Checkbox values from fields
You can also export boxes that only need to be ticked with Vaira. You can even decide how the checkboxes should be shown. The following display options are available:
- as “Yes”/“No” if it should be exported as text for ticked or not ticked,
- as “X” or “_”if it should only be shown with a cross or an underscore,
- as ☒/☐if you prefer a graphic symbol.
Here, too, you have to add a command before (or above) the checkbox:
{# EXEC
yesNo = (v) => (v? "Yes": "No");
simple = (v) => (v? "X": "_");
retro = (v) => (v? "☒": "☐");
#}
Again, you don't need to change anything here. To export boxes, there is again an almost uniform command that you only need to adapt to your needs:
{# yesNo(field("taskID/boxID")) #}
As usual, you'll find taskID here again and, this time, the boxIDto tell Vaira which box in which task you mean.
You can freely swap the yesNopart. The term in this position decides how the value is displayed. As you can see in the code you inserted before the checkboxes, the yesNocommand appears there in the second line. To the right of the equals sign, you can see what the values should look like.
So in your command, you can also replace yesNo with simple or retro to change how it's displayed.
Checkbox values from lists
You can export checkbox values from lists in a very similar way. Here, too, you place the code from above before (or above) the list:
{# EXEC
yesNo = (v) => (v? "Yes": "No");
simple = (v) => (v? "X": "_");
retro = (v) => (v? "☒": "☐");
#}
Then you create a list again, just as you did for values from lists in general:
| Material | Defect-free | Installed? | Satisfied? |
|
{# FOR item IN field("docs/componentlist") #} |
|
|
|
|
{# $item.asset #} |
{# yesNo($item.values.boxID) #} |
{# simple($item.values.boxID) #} |
{# retro($item.values.boxID) #} |
|
{# END-FOR item #} |
The first row after your header row and the last row are again only relevant for running the program and aren't exported in the end. As usual, simply enter the taskID and the listID here so that Vaira knows which list in which task you mean.
In the second row, we again show an example of how an object is structured. You can copy the first cell without changes. In the individual attribute cells, you can then choose how ticked (or unticked) boxes should be shown using yesNo, simple and retro. Replace the boxID with the correct ID of the box you want to query there.
This example would result in the following in the export:
| Material | Defect-free | Installed? | Satisfied? |
| PE coupler | Yes | X | ☒ |
| PE pipe | Yes | _ | ☐ |
| Gas excess flow valve | No | X | ☒ |
| Adhesive tape | Yes | _ | ☒ |
| Expanding foam | No | _ | ☐ |
| Paving stone | Yes | X | ☒ |
Syntax for conditions for your values in exports
You can also make settings in your export template so that certain values – such as a 0 – aren't exported at all.
In the following commands, too, you only need to adjust the values in bold to your needs; the rest is general command code and must not be changed.
Showing (or hiding) certain values in the export
If you'd rather have empty spaces than a 0 in your template, you can set this up. Of course, this also works with any other value. You do this with an additional command that you place before and after the normal command:
{# IF field("taskID/fieldID") != 0 #}
{# field("taskID/fieldID") #}
{# END-IF #}
With this command, you tell Vaira that wherever there is a 0, the 0 should not be exported. You can read the command like this:
IF the field (XY) does NOT contain 0, then
the program should insert the VALUE OF THE FIELD (XY) there.
The last line just ends the command.
taskID and fieldID – you already know these: they specify which field in which task you mean. You need to adjust them in the first and second lines. You can also change the part after the bracket in the first line as you like. The != stands for “is not”, and the 0 is the value you want to compare against. Another example:
{# IF field("taskID/fieldID") == 1 #}
{# field("taskID/fieldID") #}
{# END-IF #}
The basic form is the same again. But you've changed the condition:
IF the field (XY) contains a 1, then
the program should insert the VALUE OF THE FIELD (XY) there.
The last line just ends the command.
So here, the == stands for “is equal to”, and the 1 is our other value. Important: really use two equals signs! A single equals sign isn't enough for the command.
You can also show or hide values based on words. Here are a few examples, but we only give you the first line (the second and third lines are always the same anyway). See if you can work out which values would be shown. You'll find the solution right after:
- Example: {# IF field("taskID/fieldID") != "Pipe" #}
- Example: {# IF field("taskID/fieldID") == 112 #}
- Example: {# IF field("taskID/fieldID") != 15 #}
- Example: {# IF field("taskID/fieldID") == "Expanding foam" #}
- Example: {# IF field("taskID/fieldID") > 0 #}
- Example: {# IF field("taskID/fieldID") < 10 #}
- Example: {# IF field("taskID/fieldID") <= 6 #}
- Example: {# IF field("taskID/fieldID") >= 0 #}
The solution:
- In the first command, the value is only exported if it is not Pipe.
- In the second command, the value is only exported if it is 112.
- In the third command, the value is not exported if it is 15.
- In the fourth command, the value is only exported if it is Expanding foam.
- In the fifth command, the value is only exported if it is greater than 0.
- In the sixth command, the value is only exported if it is less than 10.
- In the seventh command, the value is only exported if it is less than or equal to 6.
- In the eighth command, the value is only exported if it is greater than or equal to 0.
When comparing with words, it's important to put them in quotation marks (as with "Pipe"). You can query numbers without quotation marks.
Syntax for formatting your exports
You can also make settings in your export template so that values meeting certain conditions are formatted in a special way.
In the following commands, too, you only need to adjust the values in bold to your needs; the rest is general command code and must not be changed.
Setting the number of decimal places
Very complex calculations are easy to do digitally. Especially when you automate calculations with Vaira, divisions, for example, can produce numbers with an extremely large number of decimal places. To keep them from messing up your export, you can use a simple command to control how many decimal places are exported:
{# field("taskID/fieldID").toFixed(3) #}
Of course, this only makes sense for fields that contain numbers. We probably don't need to tell you anymore that you have to replace taskID and fieldID with the matching values. But instead of simply outputting the value as usual, you add a .toFixed(3) after the bracket. The .toFixed() part is a fixed command that you must not change. It rounds the number to the specified number of decimal places. So the only thing that matters to you is the value in the brackets – here, the 3. It defines how many decimal places the number should have in the export. A number in Vaira such as 3.14159265359 would therefore be exported with only three decimal places: 3.142.
Tip: Vaira outputs numbers with a period as the decimal separator. If you want a comma, add .replace(".", ",") to it. Then {# field("taskID/fieldID").toFixed(3).replace(".", ",") #} becomes 3,142.






