Business Integration Solutions on-premise
How to: Create a Custom Codeunit with Expression Functions
Usage
Use this task to extend Business Integration Solutions with custom functions, for example, for use in the MAPPER activity.
Prerequisites
The following prerequisites are required:
- Experience developing in Business Central AL.
- Understanding of Business Integration Solutions and especially document mapping.
- A development license.
The SaaS version has a different interface that will become available later in the on-premise version. See here for more information.
Steps
Develop a custom codeunit with functions. Write the functions in standard AL code using familiar constructs for table access and calculations. Typically, use the arguments passed in to query data from the Business Central database and calculate a return value.
Functions can only use base types for arguments and return values. Functions should be side-effect free.
Add comments to the functions indicating category and description. BIS interprets these comments during registration. The category and description appear in the mapping wizard.
Compile the codeunit.
Register the codeunit in BIS. The Application Setup menu contains a Function Library page. From the ribbon on this page, select Register to register a codeunit. Select the codeunit from the list and import it into the system. The set of available functions extends with the functions in the selected codeunit.
If no functions appear during registration, the App source files may be protected and Business Integration Solutions cannot parse them. See Initialize BIS.
An additional set of functions becomes available for mapping.
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;