Scripts
- 1 Different types of scripts
- 2 Basic structure of a script
- 3 Elements within CustomDataNodes and their attributes
- 3.1 Line
- 3.2 Text
- 3.3 Element
- 3.4 Condition
- 3.4.1 Comparison operators
- 3.5 Snippet
- 3.6 List
- 3.7 Link
- 3.7.1 Bilder-Links
- 3.8 Image
Scripts are used to display fields from different sources (e.g. profile data or recipient dialog). Logic can also be built in by means of conditions. Finally, the goal of scripts is more dynamics and simplification in templates. Scripts to be inserted in multiple templates are stored in the Global Configurations. The document function "Scripts" then only links the script to the Global Configurations.
Each script is enclosed in the CustomDataNode
start and end tag. Each CustomDataNode
element needs the attribute id
, whose value can be freely chosen and must be unique.
To create a text script with multiple lines, the Line
element is used for one line. With the element Text
a fixed text is output:
<CustomDataNode id="ExampleScript">
<Line>
<Text>First row</Text>
</Line>
<Line>
<Text>Second row</Text>
</Line>
</CustomDataNode>
Using Element
, texts are attracted from the profile or from external sources. For example, in order for profile data to be attracted, the identification of the respective field is required. This field id can be found in the Dashboard in "Fields" in the column "FieldId":
If the field id was inserted in the id attribute, "Profile." must still be added in front of "User" (this only applies to profile fields that want to be accessed). The purpose of the scripts is also to further process the attracted data or to supplement it with texts. In the example below the attribute separator
was used as an addition. It is used between the two attracted elements salutation and first name. If no first name is drawn because none is filled in the field, the defined separator is not output:
<CustomDataNode id="FirstLastNameAndTitle">
<Line>
<Element id="Profile.User.Salutation" separator=" " />
<Element id="Profile.User.FirstName" separator=" " />
<Element id="Profile.User.LastName" />
</Line>
<Line>
<Element id="Profile.Org.Title" />
</Line>
</CustomDataNode>
With a condition
conditions can be built into the scripts:
<CustomDataNode id="ConditionExample">
<Line>
<Element id="Profile.User.Salutation" separator=" " />
<!-- Condition directly on element / AND link ↓ -->
<Element when="CustomElements.ShowFirstName = 'true' + CustomElements.DontShowFirstName = 'false'" id="Profile.User.FirstName" separator=" " />
<Element id="Profile.User.LastName" />
</Line>
<Condition notwhen="CustomElements.ShowTitle = 'false'">
<Line>
  <Element id="Profile.Org.Title" />
  </Line>
</Condition>
</CustomDataNode>
With the Snippet
element OneOffixx snippets stored in the database can be accessed.
WARNING
When using Snippet
it is a snippet script. This cannot be mixed with text (e.g. with Element
) or images (Image
). See Different script types.
In addition, when using snippet scripts, be sure to follow the following page from Best Practices: Insert snippet scripts.
The CustomDataNode
element is given the update
attribute in the example below. update
= true
causes the snippet to update or not (false
) depending on document parameter selections .
Different types of scripts
There are three different types of scripts, which must not be mixed:
Script type | Description |
---|---|
Text script | The result is a text. |
Snippet script | The result is a composition of snippets. |
Image script | The result is an image. |
Basic structure of a script
Script element
The following lines are standard in every script document function:
The third line allows scripts or dynamic binding elements to be used in templates at all. Here is an overview of the possible attributes:
Attribute | Description |
---|---|
depth | Determines how often the script result is calculated. Generally, it is recommended to link to the Depth stored in the Global Configurations, which is 5 by default. If a script accesses the result of another script, |
engine | Specifies the engine used for script interpretation/implementation. Only "XSL" is available as value. |
version | Bestimmt die Scriptengine-Version, die zur Anwendung kommt. Standardmässig ist der Wert 2. Die Angabe dieser Version könnte auch auf Ebene |
CustomDataNode element
Using CustomDataNode
a new binding element is created, in which the script content is then defined.
Attribut | Description |
---|---|
id | Id of the binding element that will be defined. The id must be unique. For better clarity in the template editor, the folder structure itself can be controlled: If an Id contains a dot, a folder is created from the word before the dot. OneOffixx puts the prefix "CustomElements." in front of each Id. This must be taken into account when accessing another script in a script. |
version | Specifies the script engine version that will be used. A specification at |
bookmarkname | Allows to specify the name of the bookmark into which the corresponding snippets will be inserted in the template editor. This attribute is only considered in connection with snippets. |
update | With |
Elements within CustomDataNodes and their attributes
Line
Using Line
element several rows are created in a script. All elements explained below are in most cases defined within the Line
start and end tags. If no element is available in a line, it will not be displayed.
Attribute | Description |
---|---|
fixoutput | By setting |
Text
Using Text
fixed texts are output.
Element
Using Element
fields are retrieved from OneOffixx. The data can be supplemented or formatted by means of the following attributes:
Attribute | Description |
---|---|
id | Id of the field to be inserted |
checkBoxActivatedSymbol | Definition of the character to be displayed when a checkbox is selected |
checkBoxDeactivatedSymbol | Definition of the character to be output when a checkbox is not selected |
linePrefix | Prefix character for each line of a list or multi-line text element |
separator | Separator text to the next element or text to be displayed only if the following element provides content |
showEmptyEndLines | Accepts all existing trailing empty lines: |
showEmptyStartLines | Accepts all existing preceding empty lines: |
textafter | Fixed text that always appears after the element. e.g. |
textbefore | Fixed text that always appears before the element. e.g. |
when | see Condition |
notwhen | see Condition |
Functions | Â |
fCase* | Defines whether the incoming text should be written |
fFormattingDate* | Defines an explicit format for a DateTime element. In general, it is always associated with the formats present in the Global Translations: |
fFormattingNumber* | Defines an explicit format for phone numbers in a text field (e.g. in the Profile.User.Phone field). |
fFormattingNumeric* | Defines an explicit format for numbers. |
fReplace* | Defines whether a part of the text should be replaced. |
fSelectLine* | Defines whether one or more lines should be selected from a multiline text. |
fSubstring* | Defines whether only a part of the text should be output. |
fSubstringAfter* | Defines whether only the end (after a given string) of the text should be output. If the delimiter is not present the whole text will be output. |
fSubstringAfterOrEmpty* | Defines whether only the end (after a given string) of the text should be output. If the delimiter is not present no text will be output. |
fSubstringBefore* | Defines whether only the beginning (before a given string) of the text should be output. If the separator is not present the whole text will be output. |
fSubstringBeforeOrEmpty* | Defines whether only the beginning (before a given string) of the text should be output. If the delimiter is not present no text will be output. |
fTrim* | Defines whether only a maximum number of characters should be output. |
fTrimURL* | Defines whether only part of a URL or file path should be output (see also fTrim). e.g. |
*This attribute can be placed in an element any number of times in succession. In this case, each attribute must be supplemented with additional characters so that each command is unique. In the following example, the fReplace attributes are numbered consecutively:
Condition
Using Condition
, entire areas can be activated or deactivated on the basis of conditions. The conditions are usually linked to selections in the document parameter. Example: "If the checkbox "DocParam.Checkbox1" is activated in the document parameter, a text will be shown." Text, CheckBox, ComboBox and Image elements can be validated. Available attributes for this element are when
and notwhen
.
Attribute | Description |
---|---|
when | Condition in order for the included elements and texts are displayed. When specifying Ids (without text comparison operators, see below) it is checked if the OneOffixx element with the Id exists and has a content. |
notwhen | Analogous to the when attribute, but inverted. |
Comparison operators
Comparison operators can also be used in a when or notwhen attribute, but fixed texts must be enclosed in single quotes ('):
Attribute | Description |
---|---|
| The content is compared 1:1. |
| The content is compared case-insensitively and without whitespace. |
| Checks whether the content contains a certain string (at any position). |
| Checks whether the content starts with certain characters. |
| Compare the number of characters |
| Checks whether the number of characters is larger. |
| Checks whether the number of characters is smaller. |
Snippet
Using Snippet
element snippets stored in OneOffixx can be used or fixed content can be filled.
WARNING
When using Snippet
it is a snippet script. This cannot be mixed with text (e.g. with Element
) or images (Image
). See Different script types.
In addition, when using snippet scripts, be sure to follow the following page from Best Practices: Insert snippet scripts.
List
Using List
a dynamic list of elements can be output. Mostly the element is used for the display of a recipient list (e.g. in a protocol). Within a list again the attributes Line
, Element
and Condition
can be used. The addressing of the Ids is now made relative, i.e. instead of Contact.Recipient.Selected.Person.FirstName only Person.FirstName is used now.
Attribute | Description |
---|---|
filter | There are the following filter criteria: "To", "Cc", "Bcc". If "To" is used, only the recipients selected with "To" will be applied. |
includeSelected | Determines whether the currently selected contact is also displayed in the list or not: |
separator | Separator text that is always displayed between the elements |
type | Determines the list type: always |
Link
Using Link
an HTML link can be created. It should be noted that no other data-attracting elements should be used in the same script. The links can only be used in HTML emails and not in combination with the normal text scripts. OneOffixx fields as well as other links can be deposited. If several link elements should be output on different lines, the end of the line must be marked with  
.
Attribute | Description |
---|---|
id | Id of the field to be used as URI. As mentioned, a fixed link can also be specified as tag content |
type | Link type – type of the link. Allowed are: |
text | Fixed text to be displayed (if different from the URI). It will only be displayed if no binding text is available. |
bindingText | Id of the binding element to be displayed as link text |
style | CSS style specifications for formatting the HTML link |
styleName | Name of a non-built-in style of type "character". The layout template is ideally based on the "hyperlink" layout template. |
when | see Condition |
notwhen | see Condition |
Bilder-Links
With Link
also images with a link can be inserted.
Image from OneOffixx field:
Fixed image:
Attribute | Description |
---|---|
bindingImage | Id of the image to be displayed, e.g. |
imageSize | Height of the image, e.g. |
imageDataBase64 | Data of the image in Base64 format |
imageAltText | Alternative text, e.g. "Profile Image" |
TIP
Often Outlook converts e-mail images before sending them, which can result in visibly poor image quality. To prevent this with PNG image files, they should be saved with bit depth 32.
This applies to images that are stored and retrieved via bindingImage
as well as images that are specified directly with imageDataBase64
.
The bit depth of PNG image files is displayed in the Windows Explorer properties In "Details – Image – Bit depth".
Image
Using Image
images that are stored in OneOffixx in the user settings can be attracted. By the when
attribute this can be shown and hidden e.g. depending on the selection in the document parameter.
Referenced images must be specified in the must be specified in the Profile data configuration.
PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland