Navigation

DI# Classes and Methods for Messages

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
NameTypeDescription

isShowMessage

boolReturns true in the web version of the email, else returns false.

isWebArchive

boolReturns true in a web archive, else returns false.
isShowMessage Property

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.
[[}]]
isWebArchive Property 

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
NameParametersDescription
istIntobject ValueValidates that the value is an integer.
isDecimalobject ValueValidates that the value is a decimal.
isDateTimeobject ValueValidates that the value is a date & time.
isDateobject ValueValidates that the value is a date.
isBoolobject Value

Validates that the value is a boolean.

isDataSourceobject ValueValidates that the value is a datasource.
ToIntobject ValueConverts the value to a 32 bit integer.
ToDecimalobject ValueConverts the value to a decimal number.
ToDateTimeobject ValueConverts an object to a date & time format.
ToDateobject Value

Converts the value to a date format.

ToBoolobject ValueConverts the value to a boolean.
Converter.isInt() Method 

Validates that the value is an integer.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isInt("123"); // Returns true
Converter.isInt("abc"); // Returns false
Converter.isDecimal() Method 

Validates that the value is a decimal.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isDecimal("1.23"); // Returns true
Converter.isDecimal("abc"); // Returns false
Converter.isDateTime() Method 

Validates that the value is a date & time.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isDateTime("2018.05.02 09:00:00"); // Returns true
Converter.isDateTime("abc"); // Returns false
Converter.isDate() Method 

Validates that the value is a date.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isDate("2018.05.02"); // Returns true
Converter.isDate("abc"); // Returns false
Converter.isBool() Method 

Validates that the value is a boolean.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isBool(1); // Returns true
Converter.isBool("1"); // Returns false
Converter.isDatasource() Method 

Validates that the value is a datasource.

Parameters

Type

Description

ValueobjectObject to validate.
Converter.isDatasource(1); // Returns true
Converter.ToInt() Method 

Converts the value to a 32-bit integer.

Parameters

Type

Description

ValueobjectObject to convert.

Note: An exception will be raised if the object passed cannot be converted to an integer.

Converter.ToInt("123"); // Returns : 123
Converter.ToInt("I have 10 apples"); // Will raise an exception
Converter.ToDecimal() Method 

Converts the value to a decimal number.

Parameters

Type

Description

ValueobjectObject to convert.

Note: An exception will be raised if the object passed cannot be converted to a decimal.

Converter.ToDecimal("1.2"); // Returns : 1.2
Converter.ToDecimal("pi = 3.1415"); // Will raise an exception
Converter.ToDateTime() Method 

Converts an object to a date & time format.

Parameters

Type

Description

ValueobjectObject 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:45
Converter.ToDateTime("Hello"); 
// Will raise an exception 
Converter.ToDate() Method 

Converts the value to a date format.

Parameters

Type

Description

ValueobjectObject 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:00
Converter.ToDate("Hello"); 
// Will raise an exception
Converter.ToBool() Method 

Converts the value to a boolean.

Parameters

Type

Description

ValueobjectObject 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 exception

Mailing Namespace

Namespace containing properties on the email sending.

Note: Available in emails only.  

Mailing Properties
NameTypeDescription
isTestBooleanReturns true if if it a test sending, else returns false.
dtMailingdatetimeReturns the date of the sending.
isTest Property 

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 sending
dtMailing Property 

Returns 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
NameTypeDescription
MessageNameStringReturns the message name.
idCategoryintReturns the ID of the communication type linked to the message.
idMessageintReturns the unique identifier of the message.
ParametersMessageParametersValuesObject containing the message parameters and their values.
MessageName Property 

Returns the message name.

[[=Message.MessageName;]] 
// Displays the message name
idCategory Property 

Returns the ID of the communication type linked to the message.

 [[=Message.idCategory;]] 
// Displays the communication type ID
idMessage Property 

Returns the unique identifier of the message.

 [[=Message.idMessage;]] 
// Displays the ID of the message
Parameters Property 

Object containing the message parameters and their values.

[[=Message.Parameters.MyParameter;]] 
// Displays the value of "MyParameter"
Message Methods
NameParametersDescription
TellAFriend()"OriginalSender" string ValueGenerated the URL to the "Tell a friend" form.
OpLink()int ValueGenerates the URL to the specified operational link.
ReadTag()
Generates the message read tag.
Optout()string ValueGenerates the URL to the unsubscription form.
WebVersion()int Value
bool Value

Generates the link to the web version of the email.

Message.TellAFriend() Method 

Generates the URL to the "Tell a friend" form.

Parameters

Type

Description

OriginalSenderstringMust be passed as is, allows to pass the contact information to the form.
CulturestringThe 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 form
Message.OpLink() Method 

Generates the URL to the specified operational link.

Parameters

Type

Description

IdentifiantintID 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" 
*/
Message.ReadTag() Method 

Generates the message read tag.

[[=Message.ReadTag();]] 
// Generates the message read tag
Message.Optout() Method 

Generates the URL to the unsubscription form.

Parameters

Type

Description

CulturestringForm culture
 <a href="[[=Message.Optout("fr-CA");]]">Désabonnement</a> 
// Generates the URL to the english unsubscription form
Message.WebVersion() Method 

Generates the link to the web version of the email.

Parameters

Type

Description

IdentifiantintIdentifier of the message version.
Full screenboolDefines 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
NameTypeDescription
idImplicitRightFlagsInt32CollectionReturns a collection of the implicit consent identifiers linked to the communication type.
idOptinFlagsInt32CollectionReturns a collection of the explicit consent identifiers linked to the communication type.
idCategoryintReturns the unique identifier of the communication type.
NamestringReturns the name of the communication type.
IsAdministrativeboolDenotes if the communication type is of administrative type by a true or false value.
idImplicitRightFlags Property 

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
idOptinFlags Property 

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
idCategory Property 

Returns the unique identifier of the communication type.

Message.Category.idCategory 
// Displays the ID of the communication type 
Name Property 

Returns the name of the communication type.

Message.Category.Name 
// Displays the name of the communication type 
isAdministrative Property 

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
NameTypeDescription
Write()string ValueDisplays specified content to screen.
Ouput.Write() Method 

Displays specified content to screen.

Parameters

Type

Description

ValuestringCharacter string to display.
[[Output.Write("MyValue");]]  // Displays MyValue to screen

System Namespace

Main Namespace containing the majority of the mostly used classes.

System Properties
NameTypeDescription
NowDateTimeReturns a DateTime object containing the current date and time.
CulturestringReturns the current culture of the application.
Now Property 

Returns a DateTime object containing the current date and time.

[[=System.Now;]] 
// returns, for example: 2018-04-09 14:40:25
Culture Property 

Returns the current culture of the application.

[[=System.Culture;]] 
// returns, for example: "en-CA"
System Methods
NomTypeDescription
Random()
  • minValue :Minimal value of the generated number
  • maxValue :Maximum value of the generated number

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
NomTypeDescription
HTMLEntities()

string Value

Returns the string encoded with HTMLEntities.

Java1()

string Value

Returns the string encoded with Java1.
Java2()string ValueReturns the string encoded with Java2.
URL()string ValueReturns the string encoded with URL.
System.Encoding.HTMLEntities() Method 

Returns the string encoded with HTMLEntities.

Parameters

Type

Description

ValuestringString to encode.
[[=System.Encoding.HTMLEntities("My string");]] 
// Returns the encoding result
System.Encoding.Java1() Method 

Returns the string encoded with Java1.

Parameters

Type

Description

ValuestringString to encode
[[=System.Encoding.Java1("My string");]] 
// Returns the encoding result
System.Encoding.Java2() Method 

Returns the string encoded with Java1.

Parameters

Type

Description

ValuestringString to encode
[[=System.Encoding.Java2("My string");]] 
// Returns the encoding result
System.Encoding.URL() Method 

Returns the string encoded with URL.

Parameters

Type

Description

ValuestringString to encode
EncodingstringEncoding format
[[=System.Encoding.URL("My string","utf-8");]] 
// Returns the encoding result

Examples 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
NameTypeDescription
NamestringReturns the name of the culture containing the language (2 lower case characters), a hyphen and the region (2 upper case characters).
LanguagestringReturns the language (2 lower case characters).
RegionstringReturns the region (2 upper case characters).
Name Property 

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"
Language Property 

Returns the language (2 lowercase characters).

System.Environment.Culture.Language; // Returns "en"
Region Property 

Returns the region (2 uppercase characters).

System.Environment.Culture.Region; // Returns "CA"

Geoloc Namespace

This namespace contains geolocalisation methods.

Geoloc Methods
NameParametersDescription
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
System.Geoloc.Distance() Method 

Returns the distance between two geographic coordinates.

Parameters

Type

Description

latitude1DecimalLatitude of the first coordinate.
longitude1DecimalLongitude of the first coordinate.
latitude2DecimalLatitude of the second coordinate.
longitude2DecimalLongitude of the second coordinate.
System.Geoloc.Distance(46.805719, -71.323384, 45.502065, -73.557709); 
// Returns 225,195974299394
System.Geoloc.GetPointFromCode() Method 

Converts a postal code to a set of geographic coordinates.

Parameters

Type

Description

countrystringCountry code
postalCode stringPostal code to convert
System.Geoloc.GetPointFromCode("CA", "G1P 2J7").Latitude; 
// Returns the decimal 46.805719
System.Geoloc.GetPointFromCode("CA", "G1P 2J7").Longitude; 
// Returns the decimal -71.323384

Tools 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
NameParametersDescription
Serialize()object objConverts an object to a JSON formatted string.
Deserialize()string strConverts a JSON formatted string to an object.
JSON.Serialize() Method 

Converts an object to a JSON formatted string.

Parameters

Type

Description

objobjectObject to convert to JSON format.
System.Tools.JSON.Serialize(new[] {"Apple", "Orange", "Banana"}); 
// Returns : ["Apple","Orange","Banana"]
JSON.Deserialize() Method 

Converts a JSON formatted string to an object.

Parameters

Type

Description

strstringJSON formatted string
System.Tools.JSON.Deserialize("MyValue"); 
// Returns MyValue
System.Tools.JSON.Deserialize("['Apple','Orange','Banana']"); 
// Returns a list containg the three elements

Math Class

Provides methods for common mathematical fonctions.

Math Methods
NameParametersDescription
Floordecimal valueReturns the greater inferior or equal integer to the specified number.
Ceilingdecimal valueReturns the smallest superior or equal integer to the specified number.
Rounddecimal valueRounds a value to the closest integer.
Rounddecimal value, int decimalsRounds a value while keeping a specified number of decimals.
Math.Floor() Method 

Returns the greater inferior or equal integer to the specified number.

Parameters

Type

Description

valuedecimalValue 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
Math.Ceiling() Method 

Returns the smallest superior or equal integer to the specified number.

Parameters

Type

Description

valuedecimalCap value.
System.Tools.Math.Ceiling(1.5); // Returns 2
System.Tools.Math.Ceiling(2); // Returns 2
System.Tools.Math.Ceiling(1.01); // Returns 2
Math.Round() Method 

Surcharges

Parameters

Description

Rounddecimal valueRounds a value to the closest integer.
Rounddecimal valueRounds 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
NameParametersDescription
isValidCodestring codeReturns "true" if code is valid, else returns "false".
Validators.isValidCode() Method 

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 True
System.Tools.Validators.EMail.isValidCode("invalidField_"); 
// Returns False
System.Tools.Validators.EMail.isValidCode("validField2"); 
// Returns True
System.Tools.Validators.EMail.isValidCode("1InvalidField"); 
// Returns False

EMail Class

Provides tools to manipulate an email address.

EMail Methods
NameParametersDescription
isValidstring emailReturns "True" if the email validates, else returns "False".
GetDomainstring emailReturns the email domain.
EMail.isValid() Method 

Returns "True" if the email validates, else returns "False".

Parameters

Type

Description

emailstringString to validate
System.Tools.Validators.EMail.isValid("user@domain.com"); 
// Returns True
System.Tools.Validators.EMail.isValid("NomAccentué@domaine.com"); 
// Returns False
System.Tools.Validators.EMail.isValid("domain.com"); 
// Returns False
System.Tools.Validators.EMail.isValid("user@domain"); 
// Returns False
EMail.GetDomain() Method 

Returns the email domain.

Parameters

Type

Description

emailstringEmail 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 string

Hash Namespace

Provides hashing methods.


SHA1Class

Provides hashing method using the SHA1 cryptographic function.

SHA1 Methods
NameParametersDescription
GetBytes()string strUses the SHA1 method in order to convert a string to a byte array.
GetString()string strReturns the result of a SHA1 hash as a string.
SHA1.GetBytes() Method 

Uses the SHA1 method in order to convert a string to a byte array.

Parameters

Type

Description

strstringString to hash.
System.Tools.Hash.SHA1.GetBytes("My string"); 
// Returns a byte array
SHA1.GetString() Method 

Returns the result of a SHA1 hash as a string.

Parameters

Type

Description

strstringString to hash.
System.Tools.Hash.SHA1.GetString("MyValue"); 
// Returns "DFFFEA589FCEA0A45711699422C7A20435B8B9A5"

SHA256 Class

Provides hashing methods using the SHA256 cryptographic function.

SHA256 Methods
NameParametersDescription
GetBytes()string strUses the SHA256 method in order to convert a string to a byte array.
GetString()string strReturns the result of a SHA256 hash as a string.
SHA256.GetBytes() Method 

Uses the SHA256 method in order to convert a string to a byte array.

Parameters

Type

Description

strstringString to hash.
System.Tools.Hash.SHA256.GetBytes("my string"); 
// Returns a byte array
SHA256.GetString() Method 

Returns the result of a SHA256 hash as a string.

Parameters

Type

Description

strstringString to hash.
System.Tools.Hash.SHA256.GetString("MyValue"); 
// Returns "83527DED182C33A2ADFF553655A7D15492EA070F89566D3ED9A8AFD7519D0C1F"

MD5 Class

Offers MD5 hashing methods.

MD5 Methods
NameParametersDescription
GetBytes()string strUses the MD5 method in order to convert a string to a byte array.
GetString()string strReturns the result of an MD5 hash as a string.
MD5.GetBytes() Method 

Uses the MD5 method in order to convert a string to a byte array.

Parameters

Type

Description

strstringString to hash.
System.Tools.Hash.MD5.GetBytes("my string"); 
// Returns a byte array
MD5.GetString() Method 

Returns the result of an MD5 hash as a string.

Parameters

Type

Description

strstringString 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
NameTypeDescription
Sender_FirstNamestring ValueContact's first name
Sender_LastNamestring ValueContact's last name
Friend_FirstNamestring Value

Friend's first name

Friend_LastNamestring Value

Friend's last name

Commentsstring Value

Contact's comments to the friend

SenderFirstName Property 

First name of the contact who filled the TellAFriend form.

[[=TellAFriend.Sender_FirstName;]] 
// Displays the contact's first name
Sender_LastName Property 

Last name of the contact who filled out the TellAFriend form.

[[=TellAFriend.Sender_LastName;]] 
// Displays the contact's last name
Friend_FirstName Property 

Friend's first name.

[[=TellAFriend.Friend_FirstName;]] 
// Displays the friend's first name
Friend_LastName Property 

Friend's last name.

[[=TellAFriend.Friend_LastName;]] 
// Displays the friend's last name
Comment Property 

Comments left to the friend.

 [[=TellAFriend.Comments;]] 
// Displays the comments left to the friend

Version Namespace

Version Properties
NameTypeDescription
CultureboolReturns the current message culture.
idMessageVersionintReturns the unique identifier of the current message.
Culture Property 

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 
[[}]]
idMessageVersion Property 

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
NameParametersDescription
isDesignMode()noneReturns 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.
VisualEditor.isDesignMode Method 

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>
[[}]]
VisualEditor.EditZone Method 

Method that allows to visually identify the edit zone in the visual editor.

Parameters

Type

Description

BlockBlockThe block to edit
ObjectdesignConfigObject 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*/
[[
VisualEditor.UICultureTranslate Method 

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

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.