Global helper functions cannot be reached from the script.
You can add some commonly used code to the script this way.

{#asset mycode.js} function beforeRender(req, res) { ... }

https://playground.jsreport.net/w/anon/ANlq4E3I