Functions
For more information: Manage import scenarios (SM206025), Manage export scenarios (SM207025).
To add functions to a formula, you can type them in the Formula text area of the dialog box or select them from the list of formula components available within the dialog box. (Select a function type to view the list of functions of the type, and then select a function.)
This topic describes and provides examples of the functions you can use in formulas, broken down by type.
Conversion functions
The available conversion functions, which are used to convert data from one data type to another, are listed below.
CBool(x)Converts the expression used as the function argument into a Boolean expression. Returns
Falseif the Boolean value is zero; otherwise, returnsTrue.Example:
=CBool([CashDiscountAmount]Here
[CashDiscountAmount]is used as the function argument.CDate(x)Converts the expression used as the function argument into a value of the Date type. The argument should be a valid date expression according to the locale selected for the import or export scenario.
Example:
=CDate('24/12/2011')Here a string is used as the function argument.
CStr(x)Converts the expression used as the function argument into a string. If the argument is
Null, the function returns a run-time error; otherwise, it returns a string.Example:
='(' +CStr([AreaCode])+')'+CStr([Phone])Here
[AreaCode]and[Phone]are used in the function argument.CDbl(x)Converts the expression defined in the function argument into a value of the
Doubletype.Example:
=CDbl(1.0/[ExchangeRate])Here
[ExchangeRate]is used in the function argument.CSng(x)Converts the expression used as the function argument into a value of the
Singletype. If the expression has a value outside the acceptable range for theSingletype, this function returns an error.Example:
=CSng([CashDiscountAmount]/[DocAmount])Here
[CashDiscountAmount]and[DocAmount]are used in the function argument.- CDec(x)
Converts the expression used as the function argument into a value of the
Decimaltype.Example:
=CDec([DocAmount]*0.015)Here
[DocAmount]is used in the function argument.- CInt(x)
Converts the expression used as the function argument into a value of the
Integertype.Example:
=CInt('2012')-Year([DocDate])Here
[DocDate]is used in the function argument.- CShort(x)
Converts a numeric value to a value of the
Shorttype.Example:
=CShort([CashDiscountAmount])Here
[CashDiscountAmount]is used as the function argument.- CLong(x)
Converts a numeric value to a value of the
Longtype.Example:
=CLong([CashDiscountAmount])Here
[CashDiscountAmount]is used as the function argument.
Text functions
Text functions are used to perform operations on text strings. The group of text functions includes the functions described below.
- LTrim(string)
Removes all leading spaces or parsing characters from the specified string, or all leading zero bytes (0) from the specified binary expression.
Example:
=LTrim(CStr([Phone]))Here
[Phone]is used as the function argument.- RTrim(string)
Removes all trailing spaces or parsing characters from the specified character expression, or all trailing zero (0) bytes from the specified binary expression.
Example:
=RTrim(CStr([AreaCode]))Here
[AreaCode]is used as the function argument.- Trim(string)
Removes all leading and trailing spaces or parsing characters from the specified character expression, or all trailing zero (0) bytes from the specified binary expression.
Example:
=Iif(Trim([Country])Here
[Country]is used in the function argument.- Format(format, argument(s))
Replaces the format item in a specified formatting string ( format ) with the text equivalent of the arguments ( arguments ).
Example:
=Format('Currency:........ {0:C}; Account:........ {1:N}', [Currency], [AccountBalance])Here
[Currency]and[AccountBalance]are used in the function argument; 0 and 1 are the specifiers indicating where the arguments will be inserted, C is the currency format specifier, and N is the number format specifier.- UCase(string)
Returns a string that has been converted to uppercase. The string argument can be any valid string expression. If string contains Null, Null is returned.
Example:
=UCase([CustomerName])Here
[CustomerName]is used as the function argument.- LCase(string)
Returns a string that has been converted to lowercase. The string argument can be any valid string expression. If string contains Null, Null is returned.
Example:
=LCase(CStr([CustomerID])Here
[CustomerID]is used in the function argument.- InStr(string, findString)
Returns the position of the first occurrence of one string ( findString ) within another ( string ).
Example:
=InStr([CustomerName], 'Inc')Here
[CustomerName]is used in the function argument.- InStrRev(string, findString)
Returns the position of the last occurrence of one string ( findString ) within another ( string ).
Example:
=InStrRev([CustomerName], 'Inc')Here
[CustomerName]is used in the function argument.- Len(string)
Returns an integer containing either the number of characters in the string or the nominal number of bytes required to store a variable.
Example:
=Len([CustomerName])Here
[CustomerName]is used as the function argument.- Left(string, length)
Returns a string containing the specified number of characters from the left side of a string. If string contains Null, Null is returned.
Example:
=Left(Trim([VendorName]), 10)Here
[VendorName]is used in the function argument.- Right(string, length)
Returns a string containing a specified number of characters from the right side of a string. If string contains Null, Null is returned.
Example:
=Right(CustomerName, 3)Here
[CustomerName]is used in the function argument.- Replace(string, oldValue, newValue)
Returns a string in which the specified substring ( oldValue ) has been replaced with another substring ( newValue ).
Example:
=Replace([Description], 'rur', 'eur')Here
[Description]is used in the function argument.- PadLeft(string, width, paddingChar)
Right-aligns the characters in a specified string (string), padding with the specified character (paddingChar) on the left up to the specified total width (width). If the actual length of the string is less than the specified width, returns the original string.
Example:
=PadLeft(CStr(Phone), 12, '_')Here
[Phone]is used in the function argument. If the actual length of the string is less than the specified width, returns the original string.- PadRight(string, width, paddingChar)
Left-aligns the characters in a specified string ( string ), padding with the specified character ( paddingChar ) on the right up to the specified total width ( width ).
Example:
=PadRight(CStr([City]), 25, '_')Here
[City]is used in the function argument. If the actual length of the string is less than the specified width, returns the original string.
Math functions
Mathematical functions, which are listed and described below, perform calculations, usually based on input values provided as arguments, and return numeric values.
- Abs(x)
Returns the absolute value of the number.
Example:
=Abs([TotalDebit]-[TotalCredit])Here
[TotalDebit]and[TotalCredit]are used in the function argument.- Floor(x)
Returns the largest integer that is not greater than the argument.
Example:
=Floor([Price]/([Cost])Here
[Price]and[Cost]are used in the function argument.- Ceiling(x)
Returns the smallest integer that is not less than the argument.
Example:
=Ceiling([Price]/[Cost])Here
[Cost]and[Price]are used in the function argument.- Round(x, decimals)
Returns a numeric expression, rounded to the specified precision ( decimals ).
Example:
=Round(([Price]-[Cost])/[Cost], 2)Here
[Cost]and[Price]are used in a function argument, and 2 is the number of decimal places.- Min(x, y)
Returns the smaller of the two values.
Example:
=Min([Price],[Cost])Here
[Cost]and[Price]are used in the function argument.- Max(x, y)
Returns the greater of the two values.
Example:
=Max({StandardCost],[AvrCost])Here
[StandardCost]and[AvrCost]are used in the function argument.- Pow(x, power)
Computes the value of x raised to the specified power ( power ).
Example:
=Pow(([Markup], 2))Here
[Markup]is used in the function argument; the function returns the mark-up value squared (or to the second power).
Date/time functions
The date/time functions, described below, perform operations on system-generated values and return values of the following types: string, numeric, or Date/time.
- Now()
Returns the current date and time according to the system date and time on the local computer.
Example:
=Now()- Today()
Returns the current date according to the system date and time on the local computer.
Example:
=Today()- NowUTC()
Returns the current date and time according to the user’s time zone.
The system gets the user’s time zone from the following sources, which are ordered by the priority from the highest to the lowest:
- User’s preferences specified in the User profile (SP203010) window.
- The employee calendar specified in the Work calendar (CS209000) window and selected for the user’s employee in the Employees (EP203000) window.
Example:
=NowUTC()- TodayUTC()
Returns the current date according to the user’s time zone.
The system gets the user’s time zone from the following sources, which are ordered by the priority from the highest to the lowest:
User’s preferences specified in the User profile (SP203010) window.
The employee calendar specified
The employee calendar specified in the Work calendar (CS209000) window and selected for the user’s employee in the Employees (EP203000) window.
Example:
=TodayUTC()- DateAdd(dt, int, nbr)
Returns a new date calculated by adding the specified number (
nbr) of time intervals (int) to the date (dt). Theintargument specifies the type of time interval and is one of the following options:- yyyy
- A number (
nbr) of years will be added to the specified date (dt). - m
- A number (
nbr) of months will be added to the specified date (dt). - y
- Same as d; see below.
- d
- A number (
nbr) of days will be added to the specified date (dt). - h
- A number (
nbr) of hours will be added to the specified date (dt). - n
- A number (
nbr) of minutes will be added to the specified date (dt). - s
- A number (
nbr) of seconds will be added to the specified date (dt).
Examples:
=DateAdd([StartPeriod], 'm', 12)=DateAdd([CashDiscountDate], 'd', -2)
In these examples,
[CashDiscountDate]and[StartPeriods]are used in the function arguments.- Year(date)
Returns the year, as an integer, extracted from the specified date (
date).Example:
=Year([StartPeriod])Here
[StartPeriod]is used as the function argument.- Month(date)
Returns the month, as an integer, extracted from the specified date (
date).Example:
=Month([StartPeriod])Here
[StartPeriod]is used as the function argument.- Day(date)
Returns the day (as an integer) extracted from the specified date (
date).Example:
=Iif(Day([DueDate]-[LeadTime])=0, True, FalseHere
[DueDate]and[LeadTime]are used in the function argument.- DayOfWeek(date)
Returns the day of the week associated with the specified date (
date) as an integer.Example:
=DayOfWeek([StartPeriod])Here
[StartPeriod]is used as the function argument.- DayOfYear(date)
Returns the day of the year calculated for the specified date (
date).Example:
=DayOfYear([StartPeriod])Here
[StartPeriod]is used as the function argument.- Minute(date)
Returns the number of minutes extracted from the specified date (
date).Example:
=Minute([StartPeriod])Here
[StartPeriod]is used as the function argument.- Second(date)
Returns the seconds extracted from the specified date (
date) as an integer.Example:
=Second([StartPeriod])Here
[StartPeriod]is used as the function argument.
Other functions
This miscellaneous group of functions includes the following functions.
- IIf(expression, truePart, falsePart)
Returns one of two values, depending on the evaluation of the expression: If the expression evaluates to
True, the function returns the truePart value; otherwise, it returns the falsePart value.Example:
=IIf(([CurrencyID]='', 'USD', [CurrencyID])Here
[CurrencyID]is used in the function argument.- Switch( expression_1, value_1, expression_2, value_2,…)
Returns the value value_n that corresponds to the first expression expression_n that evaluates to
True. expression_1, expression_2, and so on are Boolean expressions.Example:
=Switch(([DocAmount]<100), 'small', (([DocAmount]>=100)And([DocAmount]<500)), 'medium',(([DocAmount]>=500)And([DocAmount]<1000)),'large')Here
[DocAmount]is used in the function argument.- IsNull(value, nullValue)
Replaces
NULLwith the specified replacement value. The value argument is to be checked forNULL.Example:
=IsNull([CustomerID],'NULL value')Here,[CustomerID]is used in the function argument.- Sum(from, to)
- Is not applicable to formulas used by the Integration forms.
- Provider.CalculateHash(string)
Calculates the hash string for the specified string.
Example:
=Provider.CalculateHash([CUSTOMER ID] + [INVOICE REF NBR] + [LINE NBR])In this example, the hash string is calculated for the string that contains concatenated values of the
[CUSTOMER ID],[INVOICE REF NBR], and[LINE NBR]fields.- Provider.CalculateHashCode(string)
Calculates the hash code (which is an
Integervalue) for the specified string.Example:
=Provider.CalculateHash([CUSTOMER ID] + [INVOICE REF NBR] + [LINE NBR])In this example, the hash code is calculated for the string that contains concatenated values of the
[CUSTOMER ID],[INVOICE REF NBR], and[LINE NBR]fields.
Parent topic: Configuring scenario mapping