Issue Accessing Custom Global Function in Node-RED Function Node

Hi
I am trying to define a custom global function in ui_base.js and access it within a Function node in Node-RED. However, I am encountering an undefined error when attempting to use the function.

module.exports = function (RED) {
    // Register the global function when the nodes have started
    RED.events.on('nodes-started', () => {
        const globalContext = RED.runtime.context.global;
        globalContext.set('myUtilityFunction', (param) => {
            return `Processed: ${param}`;
        });
    });

    // Custom node definition here, if needed
};

Could someone help me identify what might be causing the undefined error or how to correctly set up and access the global function in Node-RED?

Thanks in advance!

Not sure why you are hacking on that D2 config node?

Would probably be better to actually explain what you are trying to achieve.

Function nodes run code in a protected VM so it is perfectly possible that trying to do the global in that config node might not reach the VM - but I don't know the internals of D2 so not sure.