Business Integration Solutions

Expression Function

An Expression Function enables Microsoft Dynamics NAV functions to be called from a mapping. NAVBIS has been provided with a collection of standard expressions which can easily be extended with custom functions. New expression functions can be included in a custom codeunit. The standard expression functions may not be modified. Expression Functions are executed in the context of the mapping. The mapping wizard can be used to map the arguments of a function with the appropriate values. In order to use Expression Functions in the Mapping Wizard the expression codeunit has to be registered in the Function Library. The registration function verifies the codeunit and extracts the metadata from the object. Examples of expression functions are: GLN Number Conversions, Item Inventory Calculations and advanced date / time manipulations.

It is not required that functions have a return value to register them. It does make them rather unsuitable for Mapping

Format

Expressions functions have the following format

Codeunit:<ID>.<FunctionName>(<Arguments>)
  • Operator: Codeunit
  • ID: depending on the implementation, the ID refers to either the Codeunit ID or the Enum ID, depending on the interface. See Expression Function
  • FunctionName: The name of the function
  • (Arguments): a list of arguments, divided by commas

Standard Expression Functions

The following list shows a collection of standard functions available in Business Integration Solutions for Microsoft Dynamics 365 Business Central. The functions from BIS are registered in the same way, codeunit BIS Function List 2 is registered during product installation.

Method name Description Arguments
XWORKDATE Gets the work date for the current session -
XUPPERCASE Converts a string to uppercase String (text)
XTODAY Gets the current date set in the operating system -
XTIME Gets the current time from the operating system -
XSTRRIGHT Copies a number of characters from the right side of a string String (text), Length (integer)
XSTRLEFT Copies a number of characters from the left side of a string String (text), Length (integer)
XSELECTSTR Retrieves a substring from a comma separated string String (text),Separator (text), Place (integer)
XLOWERCASE Converts a string to lowercase String(text)
XDELCHR Deletes one or more specific characters in a string String(text), Where ('=,<,>' ), Which (char)
XCOPYSTR Selects a substring from a specific position in a string String (text), Position (integer), Lenght (integer)
XCOMPANYNAME Gets the current company name -
XCALCDATE Calculates a new date that is based on a date expression and a reference date DateExpression (text), Date (date)
ParseDate Parses an external date format into a Date Date (text), .NET dateformat
FormatDecimal Formats a decimal to a different format Decimal (text), FormatExpression
FormatDate Formats a Date to a different format Date(text), FormatExpression
ConvertToInternal Applies a conversion table on an external value ConversionTableCode (code),ExternalValue (string)
ConvertToExternal Applies a conversion table on an internal value ConversionTableCode (code),InternalValue (string)
Base64Encode Encodes a string to a base64 value String (text)
Base64Decode Decodes a base64 encoded value to a string Base64String (text)
XIF Returns a boolean value based on a logical test and optional datatype iTxtValue(Text), iTxtLogicalTest (Text), TxtDataType (Text)
GetEnumValueFromCaption Returns a translated text value based on the Caption text and the language ID provided TableNo(Integer), FieldNo(Integer), EnumCaption(Text), TextLanguageId(Integer)
GetEnumOridinalFromCaption Returns a respective option value based on the Caption text and the language ID provided TableNo(Integer), FieldNo(Integer), EnumCaption(Text), TextLanguageId(Integer)
XStringReplace Replaces a given search text with a given replace text String(Text), SearchValue(Text), ReplaceValue(Text)
XStringReplaceAndEscape Replaces a given search text with a given replace text, but escapes any occurrence of the replace value in the original text String(Text), SearchValue(Text), ReplaceValue(Text), EscapePlaceholderValue(Text)

References

DataType Short description External Reference
DateExpression A way to calculate a date relative to the current one (e.g. End of month, tomorrow). CalcDate()
FormatExpression Define how the data is formatted, different patterns exist for different datatypes. Formatting Data

OnPrem vs Saas

Both OnPrem and Saas work with the function library setup screen, when it comes to seeing what is available in the system. There is a different method to publish these functions in these versions.

To See
Add your functions to On Premise How To: Create a Custom Codeunit with Expression Functions
Publish functions on the Cloud How To: Expose Code to the Function Interface