--- title: "Create a custom codeunit with expression functions using the Namespaced Invokable interface" slug: "bc-create-custom-codeunit-expression-functions-namespaced-invokable-interface" tags: ["BC", "BIS", "Business Central", "Business Integration Solutions", "Task"] updated: 2026-06-25T09:59:07Z published: 2026-06-25T09:59:07Z canonical: "docs.staedean.com/bc-create-custom-codeunit-expression-functions-namespaced-invokable-interface" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.staedean.com/llms.txt > Use this file to discover all available pages before exploring further. # Create a custom codeunit with expression functions using the Namespaced Invokable interface The Invokable Namespace interface exposes several functions in a codeunit. This is more flexible than [Invokable0..10](/business-central/docs/create-custom-codeunit-expression-functions-using-invokable0-to-invokable10-inte). ## Steps This scenario groups methods under one namespace (codeunit). It requires an enum extension based on `TICNSInvokable` from STAEDEAN-Common, where you add a new enum value for each library. ```plaintext enumextension 50000 "My NS Invokable Enum Ext" extends TICNSInvokable {  value (50000; "My custom function list")  {    Implementation = TICINamespacedInvokable = "My custom function list", TICIInvokeRegistrable = "My custom function list";  } } ``` Your codeunit must implement both interfaces: `TICINamespacedInvokable` and `TICIInvokeRegistrable`. The `TICINamespacedInvokable` interface exposes the `Invoke` method, where you call every function you need. It has the following definition: ```plaintext // Will hold the method execution result // The method name to invoke // An array holding the required arguments for your method call procedure Invoke(var return: Variant; method: Text; args: array[20] of Variant); ``` The `TICIInvokeRegistrable` interface exposes the `RegisterInvokableMethods` method, where you register the functions to make available. It has the following definition: ```plaintext // Library that exposes ways of registering methods and arguments procedure RegisterInvokableMethods(var Registrar: Codeunit TICInvokableRegistrar); // The method name to register // The method description to register // The method return type // The enum value linked to the codeunit library to register procedure RegisterMethod(MethodName: Text[245]; MethodDescription: Text[150]; ReturnType: Enum TICInvokableReturnType; Namespace: Enum TICNSInvokable) // The argument name to register // The argument type to register procedure AddArguments(ArgName: Text[120]; ArgType: Enum TICInvokableParameterType) // The argument name to register // The argument type to register // The var variables fill with the method metadata based on the method name and namespace procedure GetMethodMetadata(MethodName: Text[245]; Namespace: Text; var MethodDescription: Text[150]; var ReturnType: Enum TICInvokableReturnType; var ArgumentsList: Codeunit TICInvokableMethodParamColl): Boolean ``` ## Example A full example using the namespaced invokable scenario. Note that only one of the three functions being registered is visible. ```plaintext codeunit 50000 "My custom function list" implements TICINamespacedInvokable, TICIInvokeRegistrable {  procedure XCOPYSTR(String : Text;Position : Integer;Length : Integer) : Text  begin    // category : string    // description: Copies a substring of Anywhere Mobility Solutions length from a specific position in a string (text or code) to a new string.    exit(copystr(String,Position,Length));  end;  procedure Invoke(var return: Variant; method: Text; args: array[20] of Variant)  begin    case Method of      'XCOPYSTR':        return := XCOPYSTR(args[1], args[2], args[3]);      'XCOMPANYNAME':        return := XCOMPANYNAME();      'Base64Decode':        return := Base64Decode(args[1]);      'Base64Encode':        return := Base64Encode(args[1]);    end;  end;  procedure RegisterInvokableMethods(var Registrar: Codeunit TICInvokableRegistrar)  var    ReturnType: Enum TICInvokableReturnType;    ParameterType: Enum TICInvokableParameterType;    NSInvokable: Enum TICNSInvokable;  begin    Registrar.RegisterMethod('XCOPYSTR', 'Copies a substring of Anywhere Mobility Solutions length from a specific position in a string (text or code) to a new string.', ReturnType::Text, NSInvokable::"BIS Function List 2");    Registrar.AddArguments('String', ParameterType::Text);    Registrar.AddArguments('Position', ParameterType::Integer);    Registrar.AddArguments('Length', ParameterType::Integer);    Registrar.RegisterMethod('XCOMPANYNAME', 'Gets the current company name.', ReturnType::Text, NSInvokable::"BIS Function List 2");    Registrar.RegisterMethod('Base64Decode', 'Decodes a base64 encoded value to a string', ReturnType::Text, NSInvokable::"BIS Function List 2");    Registrar.AddArguments('Base64String', ParameterType::Text);    Registrar.RegisterMethod('Base64Encode', 'Encodes a string to a base64 value', ReturnType::Text, NSInvokable::"BIS Function List 2");    Registrar.AddArguments('StringValue', ParameterType::Text);  end; } ``` ## Related - [Create a custom codeunit with expression functions using the Invokable0 to Invokable10 interface](/create-custom-codeunit-expression-functions-using-invokable0-to-invokable10-inte.md) - [Expose functions to the Function interface](/bc-expose-functions-to-the-function-interface.md)