This article presents all the methods you can use when coding messages in Dialog Insight using the language DI#.
**Note that this documentation is intended for partners.**
Config Namespace
Offers message configuration properties.
Note: Available in emails only.
| Config Properties | ||
|---|---|---|
| Name | Type | Description |
isShowMessage | bool | Returns true in the web version of the email, else returns false. |
isWebArchive | bool | Returns true in a web archive, else returns false. |
Returns true in the web version of the email, else returns false.
[[if (Config.isShowMessage) {]]
You are in the web version.
// This text will be displayed in the web version of the email.
[[}]]Returns true in a web archive, else returns false.
[[if (Config.isWebArchive) {]]
You are in the web archive.
// This text will will be displayed in the web archive of the message.
[[}]]Converter Class
Converts a value to another format.
Converter Methods | ||
|---|---|---|
| Name | Parameters | Description |
| istInt | object Value | Validates that the value is an integer. |
| isDecimal | object Value | Validates that the value is a decimal. |
| isDateTime | object Value | Validates that the value is a date & time. |
| isDate | object Value | Validates that the value is a date. |
| isBool | object Value | Validates that the value is a boolean. |
| isDataSource | object Value | Validates that the value is a datasource. |
| ToInt | object Value | Converts the value to a 32 bit integer. |
| ToDecimal | object Value | Converts the value to a decimal number. |
| ToDateTime | object Value | Converts an object to a date & time format. |
| ToDate | object Value | Converts the value to a date format. |
| ToBool | object Value | Converts the value to a boolean. |
Validates that the value is an integer.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isInt("123"); // Returns trueConverter.isInt("abc"); // Returns falseValidates that the value is a decimal.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isDecimal("1.23"); // Returns trueConverter.isDecimal("abc"); // Returns falseValidates that the value is a date & time.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isDateTime("2018.05.02 09:00:00"); // Returns trueConverter.isDateTime("abc"); // Returns falseValidates that the value is a date.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isDate("2018.05.02"); // Returns trueConverter.isDate("abc"); // Returns falseValidates that the value is a boolean.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isBool(1); // Returns true
Converter.isBool("1"); // Returns falseValidates that the value is a datasource.
Parameters | Type | Description |
| Value | object | Object to validate. |
Converter.isDatasource(1); // Returns true
Converts the value to a 32-bit integer.
Parameters | Type | Description |
| Value | object | Object to convert. |
Note: An exception will be raised if the object passed cannot be converted to an integer.
Converter.ToInt("123"); // Returns : 123Converter.ToInt("I have 10 apples"); // Will raise an exceptionConverts the value to a decimal number.
Parameters | Type | Description |
| Value | object | Object to convert. |
Note: An exception will be raised if the object passed cannot be converted to a decimal.
Converter.ToDecimal("1.2"); // Returns : 1.2Converter.ToDecimal("pi = 3.1415"); // Will raise an exceptionConverts an object to a date & time format.
Parameters | Type | Description |
| Value | object | Object to convert. |
Note: An exception will be raised if the object passed cannot be converted to a date/time format.
Converter.ToDateTime("2016.01.01 12:30:45");
// Returns a DateTime object that contains 2016.01.01 12:30:45Converter.ToDateTime("Hello");
// Will raise an exception Converts the value to a date format.
Parameters | Type | Description |
| Value | object | Object to convert. |
Note: An exception will be raised if the object passed cannot be converted to a date.
Converter.ToDate("2016.01.01");
// Returns a date containing 2016.01.01 00:00:00Converter.ToDate("Hello");
// Will raise an exceptionConverts the value to a boolean.
Parameters | Type | Description |
| Value | object | Object to convert. |
Note: n exception will be raised if the object passed cannot be converted to a boolean.
Converter.ToBool(1); // Returns : True
Converter.ToBool(0); // Returns : False
Converter.ToBool("Hello"); // Will raise an exceptionMailing Namespace
Namespace containing properties on the email sending.
Note: Available in emails only.
Mailing Properties | ||
|---|---|---|
| Name | Type | Description |
| isTest | Boolean | Returns true if if it a test sending, else returns false. |
| DtMailing | datetime | Returns the date of the sending according to the timezone of the server you are using (Canada/EST or France). |
| DtScheduledDelivery | datetime | Returns the date of the sending for the timezone of the contact or the project depending on the timezone configuration. |
Returns true if if it a test sending, else returns false.
[[if (Mailing.isTest) {]]
This is a test sending.
[[}]]
// This content will only display in a test sendingReturns the date of the sending.
[[=Mailing.dtMailing;]] // Returns a full datetime of the moment of the sending
Message Namespace
Namespace containing properties, methods and classes usable in email.
Message Properties | ||
|---|---|---|
| Name | Type | Description |
| MessageName | String | Returns the message name. |
| idCategory | int | Returns the ID of the communication type linked to the message. |
| idMessage | int | Returns the unique identifier of the message. |
| Parameters | MessageParametersValues | Object containing the message parameters and their values. |
Returns the message name.
[[=Message.MessageName;]] // Displays the message name
Returns the ID of the communication type linked to the message.
[[=Message.idCategory;]] // Displays the communication type ID
Returns the unique identifier of the message.
[[=Message.idMessage;]] // Displays the ID of the message
Object containing the message parameters and their values.
[[=Message.Parameters.MyParameter;]] // Displays the value of "MyParameter"
| Message Methods | ||
|---|---|---|
| Name | Parameters | Description |
| TellAFriend() | "OriginalSender" string Value | Generated the URL to the "Tell a friend" form. |
| OpLink() | int Value | Generates the URL to the specified operational link. |
| ReadTag() | Generates the message read tag. | |
| Optout() | string Value | Generates the URL to the unsubscription form. |
| WebVersion() | int Value bool Value | Generates the link to the web version of the email. |
Generates the URL to the "Tell a friend" form.
Parameters | Type | Description |
| OriginalSender | string | Must be passed as is, allows to pass the contact information to the form. |
| Culture | string | The culture to be used by the form. |
<a href="[[=Message.TellAFriend("OriginalSender","fr-CA");]]
" target="_blank">Send to a Friend</a>
// Generates the link towards the english version of the formGenerates the URL to the specified operational link.
Parameters | Type | Description |
| Identifiant | int | ID of the operational link. |
<a href="[[=Message.OpLink(1);]]">Lien opérationel</a> /* Generates the URL of the operational link with the unique identifier of "1" */
Generates the message read tag.
[[=Message.ReadTag();]] // Generates the message read tag
Generates the URL to the unsubscription form.
Parameters | Type | Description |
| Culture | string | Form culture |
<a href="[[=Message.Optout("fr-CA");]]">Désabonnement</a>
// Generates the URL to the english unsubscription formGenerates the link to the web version of the email.
Parameters | Type | Description |
| Identifiant | int | Identifier of the message version. |
| Full screen | bool | Defines if the web version should be displayed full screen, true or false. |
<a href="[[=Message.WebVersion(1,true);]]">Version web</a> // Generates the URL to the full screen web version
Category Namespace
This namespace contains the properties of the communication type linked to the message.
Category Properties | ||
|---|---|---|
| Name | Type | Description |
| idImplicitRightFlags | Int32Collection | Returns a collection of the implicit consent identifiers linked to the communication type. |
| idOptinFlags | Int32Collection | Returns a collection of the explicit consent identifiers linked to the communication type. |
| idCategory | int | Returns the unique identifier of the communication type. |
| Name | string | Returns the name of the communication type. |
| IsAdministrative | bool | Denotes if the communication type is of administrative type by a true or false value. |
Returns a collection of the implicit consent identifiers linked to the communication type.
// If we assume that the communication type has two linked implicits Message.Category.idImplicitRightFlags // Returns the array [1,5] Message.Category.idImplicitRightFlags[0] // Returns 1 Message.Category.idImplicitRightFlags[1] // Returns 5
Returns a collection of the explicit consent identifiers linked to the communication type.
// If we assume that the communication type has two linked implicits Message.Category.idOptinFlags// Returns the array [2,3] Message.Category.idOptinFlags[0] // Returns 2 Message.Category.idOptinFlags[1] // Returns 3
Returns the unique identifier of the communication type.
Message.Category.idCategory // Displays the ID of the communication type
Returns the name of the communication type.
Message.Category.Name // Displays the name of the communication type
Denotes if the communication type is of administrative type by a true or false value.
Message.Category.IsAdministrative // Returns true or false
Output Class
Allows the output of content on screen.
| Ouput Methods | ||
|---|---|---|
| Name | Type | Description |
| Write() | string Value | Displays specified content to screen. |
Displays specified content to screen.
Parameters | Type | Description |
| Value | string | Character string to display. |
[[Output.Write("MyValue");]] // Displays MyValue to screenSystem Namespace
Main Namespace containing the majority of the mostly used classes.
| System Properties | ||
|---|---|---|
| Name | Type | Description |
| Now | DateTime | Returns a DateTime object containing the current date and time. |
| Culture | string | Returns the current culture of the application. |
Returns a DateTime object containing the current date and time.
[[=System.Now;]] // returns, for example: 2018-04-09 14:40:25
Returns the current culture of the application.
[[=System.Culture;]] // returns, for example: "en-CA"
| System Methods | ||
|---|---|---|
| Nom | Type | Description |
| Random() |
| Returns a random number in the range between the provided numbers as parameters. |
System.Random(2468, 9876); // Returns 3419
Encoding Namespace
This namespace contains methods allowing string encoding.
| System Methods | ||
|---|---|---|
| Nom | Type | Description |
| HTMLEntities() | string Value | Returns the string encoded with HTMLEntities. |
| Java1() | string Value | Returns the string encoded with Java1. |
| Java2() | string Value | Returns the string encoded with Java2. |
| URL() | string Value | Returns the string encoded with URL. |
Returns the string encoded with HTMLEntities.
Parameters | Type | Description |
| Value | string | String to encode. |
[[=System.Encoding.HTMLEntities("My string");]]
// Returns the encoding resultReturns the string encoded with Java1.
Parameters | Type | Description |
| Value | string | String to encode |
[[=System.Encoding.Java1("My string");]]
// Returns the encoding resultReturns the string encoded with Java1.
Parameters | Type | Description |
| Value | string | String to encode |
[[=System.Encoding.Java2("My string");]]
// Returns the encoding resultReturns the string encoded with URL.
Parameters | Type | Description |
| Value | string | String to encode |
| Encoding | string | Encoding format |
[[=System.Encoding.URL("My string","utf-8");]]
// Returns the encoding resultExamples of encoding formats that are accepted: UTF-8, ASCII, ISO-8859-1, Windows-1252
Environment Namespace
This namespace contains utilitary classes usable globally in different projects.
Culture Class
This class returns environnement culture.
| Culture Properties | ||
|---|---|---|
| Name | Type | Description |
| Name | string | Returns the name of the culture containing the language (2 lower case characters), a hyphen and the region (2 upper case characters). |
| Language | string | Returns the language (2 lower case characters). |
| Region | string | Returns the region (2 upper case characters). |
Returns the name of the culture containing the language (2 lower case characters), a hyphen and the region (2 upper case characters).
System.Environment.Culture.Name; // Returns "en-CA"
Returns the language (2 lowercase characters).
System.Environment.Culture.Language; // Returns "en"
Returns the region (2 uppercase characters).
System.Environment.Culture.Region; // Returns "CA"
Geoloc Namespace
This namespace contains geolocalisation methods.
| Geoloc Methods | ||
|---|---|---|
| Name | Parameters | Description |
| Distance() | Decimal latitude1 Decimal longitude 1 Decimal latitude 2 Decimal longitude 2 | Returns the distance between two geographic coordinates. |
GetPointFromCode() | string country string postalCode | Converts a postal code to a set of geographic coordinates Supported country codes: CA, US Requires a licence |
Returns the distance between two geographic coordinates.
Parameters | Type | Description |
| latitude1 | Decimal | Latitude of the first coordinate. |
| longitude1 | Decimal | Longitude of the first coordinate. |
| latitude2 | Decimal | Latitude of the second coordinate. |
| longitude2 | Decimal | Longitude of the second coordinate. |
System.Geoloc.Distance(46.805719, -71.323384, 45.502065, -73.557709); // Returns 225,195974299394
Converts a postal code to a set of geographic coordinates.
Parameters | Type | Description |
| country | string | Country code |
| postalCode | string | Postal code to convert |
System.Geoloc.GetPointFromCode("CA", "G1P 2J7").Latitude;
// Returns the decimal 46.805719System.Geoloc.GetPointFromCode("CA", "G1P 2J7").Longitude;
// Returns the decimal -71.323384Tools Namespace
This namespace contains utilitary classes usable globally in different projects.
JSON Class
Offers tools that allow conversions between an object and a JSON formatted string.
| JSON Methods | ||
|---|---|---|
| Name | Parameters | Description |
| Serialize() | object obj | Converts an object to a JSON formatted string. |
| Deserialize() | string str | Converts a JSON formatted string to an object. |
Converts an object to a JSON formatted string.
Parameters | Type | Description |
| obj | object | Object to convert to JSON format. |
System.Tools.JSON.Serialize(new[] {"Apple", "Orange", "Banana"});
// Returns : ["Apple","Orange","Banana"]Converts a JSON formatted string to an object.
Parameters | Type | Description |
| str | string | JSON formatted string |
System.Tools.JSON.Deserialize("MyValue");
// Returns MyValueSystem.Tools.JSON.Deserialize("['Apple','Orange','Banana']");
// Returns a list containg the three elementsMath Class
Provides methods for common mathematical fonctions.
| Math Methods | ||
|---|---|---|
| Name | Parameters | Description |
| Floor | decimal value | Returns the greater inferior or equal integer to the specified number. |
| Ceiling | decimal value | Returns the smallest superior or equal integer to the specified number. |
| Round | decimal value | Rounds a value to the closest integer. |
| Round | decimal value, int decimals | Rounds a value while keeping a specified number of decimals. |
Returns the greater inferior or equal integer to the specified number.
Parameters | Type | Description |
| value | decimal | Value to round. |
System.Tools.Math.Floor(1.5); // Returns 1
System.Tools.Math.Floor(1); // Returns 1
System.Tools.Math.Floor(1.99); // Returns 1
Returns the smallest superior or equal integer to the specified number.
Parameters | Type | Description |
| value | decimal | Cap value. |
System.Tools.Math.Ceiling(1.5); // Returns 2
System.Tools.Math.Ceiling(2); // Returns 2
System.Tools.Math.Ceiling(1.01); // Returns 2
Surcharges | Parameters | Description |
| Round | decimal value | Rounds a value to the closest integer. |
| Round | decimal value | Rounds a value while keeping a specified number of decimals. |
System.Tools.Math.Round(1.68); // Returns 2
System.Tools.Math.Round(1.68, 1); // Returns 1,7
Validators Namespace
Provides methods to validate data.
| Validators Methods | ||
|---|---|---|
| Name | Parameters | Description |
| isValidCode | string code | Returns "true" if code is valid, else returns "false". |
Returns "true" if code is valid, else returns "false".
Note: A code may only contain alphanumeric characters and underscores. The first character must be a letter, and it cannot end with an underscore.
System.Tools.Validators.EMail.isValidCode("myValidField");
// Returns TrueSystem.Tools.Validators.EMail.isValidCode("invalidField_");
// Returns FalseSystem.Tools.Validators.EMail.isValidCode("validField2");
// Returns TrueSystem.Tools.Validators.EMail.isValidCode("1InvalidField");
// Returns FalseEMail Class
Provides tools to manipulate an email address.
| EMail Methods | ||
|---|---|---|
| Name | Parameters | Description |
| isValid | string email | Returns "True" if the email validates, else returns "False". |
| GetDomain | string email | Returns the email domain. |
Returns "True" if the email validates, else returns "False".
Parameters | Type | Description |
| string | String to validate |
System.Tools.Validators.EMail.isValid("user@domain.com");
// Returns TrueSystem.Tools.Validators.EMail.isValid("NomAccentué@domaine.com");
// Returns FalseSystem.Tools.Validators.EMail.isValid("domain.com");
// Returns FalseSystem.Tools.Validators.EMail.isValid("user@domain");
// Returns FalseReturns the email domain.
Parameters | Type | Description |
| string | Email address as a string. |
System.Tools.Validators.EMail.GetDomain("user@domain.com");
// Returns : "domain.com"System.Tools.Validators.EMail.GetDomain("domain.com");
// Returns an empty stringHash Namespace
Provides hashing methods.
SHA1Class
Provides hashing method using the SHA1 cryptographic function.
| SHA1 Methods | ||
|---|---|---|
| Name | Parameters | Description |
| GetBytes() | string str | Uses the SHA1 method in order to convert a string to a byte array. |
| GetString() | string str | Returns the result of a SHA1 hash as a string. |
Uses the SHA1 method in order to convert a string to a byte array.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.SHA1.GetBytes("My string");
// Returns a byte arrayReturns the result of a SHA1 hash as a string.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.SHA1.GetString("MyValue");
// Returns "DFFFEA589FCEA0A45711699422C7A20435B8B9A5"SHA256 Class
Provides hashing methods using the SHA256 cryptographic function.
| SHA256 Methods | ||
|---|---|---|
| Name | Parameters | Description |
| GetBytes() | string str | Uses the SHA256 method in order to convert a string to a byte array. |
| GetString() | string str | Returns the result of a SHA256 hash as a string. |
Uses the SHA256 method in order to convert a string to a byte array.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.SHA256.GetBytes("my string");
// Returns a byte arrayReturns the result of a SHA256 hash as a string.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.SHA256.GetString("MyValue");
// Returns "83527DED182C33A2ADFF553655A7D15492EA070F89566D3ED9A8AFD7519D0C1F"MD5 Class
Offers MD5 hashing methods.
| MD5 Methods | ||
|---|---|---|
| Name | Parameters | Description |
| GetBytes() | string str | Uses the MD5 method in order to convert a string to a byte array. |
| GetString() | string str | Returns the result of an MD5 hash as a string. |
Uses the MD5 method in order to convert a string to a byte array.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.MD5.GetBytes("my string");
// Returns a byte arrayReturns the result of an MD5 hash as a string.
Parameters | Type | Description |
| str | string | String to hash. |
System.Tools.Hash.MD5.GetString("MyValue");
// Returns "72F5D0C22D11F32C518782894629FB5A"TellAFriend Namespace
Namespace containing data on the contact who sent a message to a friend.
| TellAFriend Properties | ||
|---|---|---|
| Name | Type | Description |
| Sender_FirstName | string Value | Contact's first name |
| Sender_LastName | string Value | Contact's last name |
| Friend_FirstName | string Value | Friend's first name |
| Friend_LastName | string Value | Friend's last name |
| Comments | string Value | Contact's comments to the friend |
First name of the contact who filled the TellAFriend form.
[[=TellAFriend.Sender_FirstName;]] // Displays the contact's first name
Last name of the contact who filled out the TellAFriend form.
[[=TellAFriend.Sender_LastName;]] // Displays the contact's last name
Friend's first name.
[[=TellAFriend.Friend_FirstName;]] // Displays the friend's first name
Friend's last name.
[[=TellAFriend.Friend_LastName;]] // Displays the friend's last name
Comments left to the friend.
[[=TellAFriend.Comments;]] // Displays the comments left to the friend
Version Namespace
| Version Properties | ||
|---|---|---|
| Name | Type | Description |
| Culture | bool | Returns the current message culture. |
| idMessageVersion | int | Returns the unique identifier of the current message. |
Returns the current message culture.
// In a message that has the culture "en-CA"
[[=Version.Culture;]] // Displays "en-CA"
// The following conditiuon will display « English »
[[if (Version.Culture == "fr-CA") {]]
Français
[[}else{]]
English
[[}]]Returns the unique identifier of the current message.
// In a message that has only one version [[=Version.idMessageVersion;]] // Displays 1
VisualEditor Namespace
Namespace containing configuration methods of the visual editor.
| VisualEditor Methods | ||
|---|---|---|
| Name | Parameters | Description |
| isDesignMode() | none | Returns true if in edition mode, else returns false. |
| EditZone() | Block Object designConfig | Visual indicator of the edit zone of the visual editor. |
| UICultureTranslate() | string French text string English text | Automatic translation according to context. |
Method that allows to determine if we are in edit mode.
[[if (VisualEditor.IsDesignMode()) {]]
<div>This div is only visible in edit mode.</div>
[[}]]
[[if (VisualEditor.IsDesignMode() == false) {]]
<div>This div is not visible in edit mode.</div>
[[}]]Method that allows to visually identify the edit zone in the visual editor.
Parameters | Type | Description |
| Block | Block | The block to edit |
| Object | designConfig | Object containing the edit zone config |
datasource dsCustomDesignConfig =
{ EditedProviders:{block_Layout.Styles},
ToolPosition:"Inside", ToolSide:"Top",
ToolAlign:"Right",
SmallDragHelper:true,
EditedProvidersShouldOverride: true };
// Edit zone config
]]
<div class="MainContent"
[[ VisualEditor.EditZone(block_Layout, dsCustomDesignConfig);]]>
My content
</div>
/* Visual edition of the block "block_Layout"
will be available on the previous div, according
to the config set previously*/
[[Automatic translation according to context.
[[=VisualEditor.UICultureTranslate("Je suis", "I am");]]
// If the application context is in french, "Je suis" will be displayed.
// If the context is english, "I am" will be displayed