Create formula

In this article we‘ll look at an important point in your synchronization rules and one of the many setting options offered by Myddleware, formulas.

 

The fundamentals

For starters, formulas allow you to format or to set the values that will be sent to a given target field . In other words, you have the option of adding fixed text to all uppercase, change timezones, concatenate several source fields etc.

 

The syntaxe

To help, syntax highlighting (1) is available to you right on your text box. Furthermore you will find below, the list of source fields that you have chosen (2), the available functions and their categories (3) and one or two drop list(s) (4) of the different values for the list type fields (as SalutationID example).

blog-formules

Examples:

– Concatenate multiple fields, Myddleware uses the « . » as in PHP {field1}.{field2}.{fields3}

– Concatenate a fixed text with one or multiple fields « Client Name: « .{Firstname}. » « .{Lastname}

Three-valued condition , « If the Greeting field is ‘Mr.’ then send 1, otherwise send 2 » is written as followed : (({Greeting} == « Mr. ») ? « 1 » : « 2 »), those three-valued conditions can be nested in order, for example, to make the data correspond. Thus, ({resolution} == « 10 » ? « Open » : ({resolution} == « 20 » ? « Fixed » : ({resolution} == « 30 » ? « Reopened » : « Suspended »))) is correct and functional, this formula means « If resolution is 10 then ‘Open’ is sent, otherwise if resolution is 20 then ‘Fixedis sent, otherwise if resolution is 30 then Reopened’ is sent, otherwise Suspended ‘ is sent.

– Add two fileds {field1} + {field2}

 

Functions

 

In the formula of Myddleware, you can use the functions listed at the bottom right (see (3) of the previous image).

 

round(numbre [, clarification)(PHP) Ex: round(525.6352, 2) // Gives 525.64

This function round floating point (up).

 

ceil(float)(PHP) Ex: ceil(525.6352) // gives 526

Rounds up.

 

abs(number)(PHP) Ex: abs(-5) // gives 5

Returns the absolute value.

 

trim(string [, Masque])(PHP) Ex: trim( » bonjour « ) returns « bonjour »

Deletes spaces (or other charachters) at the begenning and the end of a string.

 

lower(STRING)(PHP) Ex: lower(« BONJOUR ») returns « bonjour »

Lowercases all charachters.

 

upper(Strin)(PHP) Ex: upper(« bonjour ») returns « BONJOUR »

Uppercases all charachters.

 

date(Format [, Timestamp])(PHP) Ex: date(« Y:m:d ») returns « 2014:09:16 »

Formats a local date/hour.

 

microtime([true if you want a float result])(PHP) Ex: microtime(true) returns 1410338028.5745

Returns current Unix timestamp with microseconds.

 

changeTimeZone(Date you want to change, old timezone, new timezone)(PHP) Ex: changeTimeZone(« 2014-09-16 12:00:00 », « America/Denver », « America/New_York ») returns « 2014-09-16 14:00:00 »

Changes the timezone of the given date.

 

changeFormatDate(Date you want to change, New format) Ex: changeTimeZone(« 2014-09-16 12:00:00 », « Y/m/d H:i:s ») returns « 2014/09/16 12:00:00 »

Changes the format of the given date.

 

substr(String, Index)(PHP) Ex: substr(« abcdef », -1) returns « f »

Reads a string starting of the given Index.

 

striptags(String)(PHP) Ex: striptags(« <p>Test paragraph.</p><!– Comment –> <a href= »#fragment »>Other text</a> ») returns « Test paragraph. Other text »

Strips HTML and PHP tags from a string.