<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Access other scripts]]></title><description><![CDATA[<p>The docs say you can have global scripts, but how do you access functions defined in those scripts? I tried to add them to the req object in the global script beforeRender, but that didn't stick. Any help is appreciated.</p>
<p>Thanks</p>
]]></description><link>https://forum.jsreport.net/topic/60/access-other-scripts</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 16:55:47 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/60.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Apr 2017 22:10:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Access other scripts on Invalid Date]]></title><description><![CDATA[<p>The docs say you can have global scripts, but how do you access functions defined in those scripts? I tried to add them to the req object in the global script beforeRender, but that didn't stick. Any help is appreciated.</p>
<p>Thanks</p>
]]></description><link>https://forum.jsreport.net/post/231</link><guid isPermaLink="true">https://forum.jsreport.net/post/231</guid><dc:creator><![CDATA[rodriguise]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Access other scripts on Invalid Date]]></title><description><![CDATA[<p>do you mean like defining a helper function in the global script and access it from your template? if so, here is an example -&gt; <a href="https://playground.jsreport.net/studio/workspace/SkQYIQhae/9" rel="nofollow">https://playground.jsreport.net/studio/workspace/SkQYIQhae/9</a></p>
<p>note that you can achieve the same using <a href="https://jsreport.net/learn/assets" rel="nofollow">assets</a> extension, defining functions in an asset file, and just importing the asset in your template's helpers, here is another example using asset -&gt; <a href="https://playground.jsreport.net/studio/workspace/BJP7eMYTe/10" rel="nofollow">https://playground.jsreport.net/studio/workspace/BJP7eMYTe/10</a></p>
]]></description><link>https://forum.jsreport.net/post/232</link><guid isPermaLink="true">https://forum.jsreport.net/post/232</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Access other scripts on Invalid Date]]></title><description><![CDATA[<p>No neither of those are what I am taking about. I have a server-side js library with a bunch of util methods I'd like to call from other scripts. These are not used in the templates themselves, but to generate data for the template.</p>
]]></description><link>https://forum.jsreport.net/post/233</link><guid isPermaLink="true">https://forum.jsreport.net/post/233</guid><dc:creator><![CDATA[rodriguise]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Access other scripts on Invalid Date]]></title><description><![CDATA[<p>i'm afraid that there is no way to assign functions in a script and be able to call the function in another script, jsreport for security reasons by default execute scripts in another process, functions can't be passed across these processes, however to do what you want you have some options:</p>
<ul>
<li>store your functions in an asset file and just import the asset in every script where you need your functions, example: <a href="https://playground.jsreport.net/studio/workspace/BJP7eMYTe/22" rel="nofollow">https://playground.jsreport.net/studio/workspace/BJP7eMYTe/22</a></li>
<li>save your functions in a file, and just require that file in your scripts. <code>var functions = require('./path/to/functions.js')</code></li>
</ul>
]]></description><link>https://forum.jsreport.net/post/235</link><guid isPermaLink="true">https://forum.jsreport.net/post/235</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>