Business Integration Solutions documentation
Expression Function
An Expression Function lets you call Microsoft Dynamics NAV functions from a mapping. BIS provides a collection of standard expressions that you can easily extend with custom functions. Add new expression functions in a custom codeunit. You cannot modify the standard expression functions. Expression functions execute in the context of the mapping. Use the mapping wizard to map the arguments of a function with the appropriate values. To use expression functions in the Mapping Wizard, register the expression codeunit in the Function Library. The registration function verifies the codeunit and extracts the metadata from the object. Examples of expression functions include GLN number conversions, item inventory calculations, and advanced date and time manipulations.
A return value is not required to register a function, though functions without a return value are not suitable for Mapping.
Format
Expression 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, on-premise vs SaaS.
- FunctionName: The name of the function.
- (Arguments): A list of arguments, separated by commas.
Standard expression functions
The following list shows the standard functions available in Business Integration Solutions for Microsoft Dynamics 365 Business Central. The functions from BIS register via codeunit BIS Function List 2, which registers 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), Length (integer) |
| XCOMPANYNAME | Gets the current company name. | : |
| XCALCDATE | Calculates a new date 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 date format |
| 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 language ID. | TableNo (Integer), FieldNo (Integer), EnumCaption (Text), TextLanguageId (Integer) |
| GetEnumOrdinalFromCaption | Returns an option value based on the caption text and language ID. | 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, for example, end of month or tomorrow. | CalcDate() |
| FormatExpression | Defines how data formats. Different patterns exist for different datatypes. | Formatting Data |
On-premise vs SaaS
Both on-premise and SaaS use the Function Library setup page to see what is available in the system. The method for publishing functions differs between 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 |