Business Integration Solutions OnPrem
How To: Create a Custom Codeunit with Expression Functions
Expressions expose select functions made in Microsoft 365 Business Central to Business Integration Solutions. It is possible to add custom functions to the set of available functions. For exposing functions
Usage
Use this task when you want to extend the Business Integration Solutions with custom functions. For use in e.g. the MAPPER activity.
Prerequisites
The following prerequisites are required
- Experience in developing in Business Central AL
- Understanding of Business Integration Solutions and especially the mapping of documents
- A development license
The SaaS version has a different interface which will become available later in the On Premise version. See here for more info
Steps
- Develop a custom codeunit with functions. The functions are developed in standard AL code, with the familiar constructs for table access and calculations. Typically one would use the arguments that are passed in to query data from the Business Central database and then calculate a return value.
Note: The functions can only use base types for arguments and return value. The functions should be side-effect free.
- Add comments to the functions indicating category and description. The comments are interpreted by the BIS registration function. The category and description are shown in the mapping wizard.
- Compile the codeunit.
- Register the codeunit in BIS. The Application Setup menu contains a Function Library page. In the ribbon of this page you can Register a codeunit. You select the codeunit for the list and import it into the system. The set of available functions is extended with the functions in the selected codeunit.
A additional set of functions becomes available for mapping.
In case there are no functions displayed during registration, often the App source files are protected and Business Integration Solutions cannot parse them. See Initialize BIS
Example
The following function is defined in the BIS standard function library.
procedure XCOPYSTR(String : Text;Position : Integer;Length : Integer) : Text
begin
//**********************************************************
// category : string
// description: Copies a substring of any length from a specific position in a string (text or code) to a new string.
//**********************************************************
EXIT(COPYSTR(String,Position,Length));
end;