<?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[after argument list sandbox.js:16]]></title><description><![CDATA[<p>Postgres report</p>
<pre><code>Render request 16 queued for execution and waiting for availible worker
info+7Starting rendering request 16 (user: admin)
info+3Rendering template { name: Daily_State_Balance(clone), recipe: html-to-xlsx, engine: handlebars, preview: true }
debug+4Data item not defined for this template.
debug+3Executing script dev11db-test (beforeRender)
error+10Error when processing render request 16 Error when evaluating custom script /Dev11/dev11db-test
missing ) after argument list sandbox.js:16
    const res = await client.query('with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1  as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on a.id = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;') 
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: missing ) after argument list
    at new Script (node:vm:100:7)
    at doCompileScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/createSandbox.js:224:14)
    at run (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/createSandbox.js:169:72)
    at WorkerReporter._runInSandbox (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/runInSandbox.js:163:12)
    at WorkerReporter.runInSandbox (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:152:17)
    at async executeScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/executeScript.js:122:12)
    at async Scripts._runScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/worker.js:140:30)
    at async Scripts.handleBeforeRender (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/worker.js:64:7)
    at async ListenerCollection.fire (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/shared/listenerCollection.js:157:21)
    at async beforeRender (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:25:5)
    at async WorkerReporter._render (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:146:7)
    at async /home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:179:19
    at async Domain.&lt;anonymous&gt; (/home/ubuntu/jsreportapp/node_modules/@jsreport/advanced-workers/lib/workerHandler.js:141:19)
error+0Rendering request 16 finished with error in 27 ms
</code></pre>
<p>DATA script</p>
<pre><code>async function afterRender (req, res) {
  const { Client } = require('pg')

  const credentials = {
    user: 'sddev',
    host: 'dev11-ro-database-01.************.us-east-2.rds.amazonaws.com',
    database: 'ats_whitelabel',
    password: '*************',
    port: 5432
  }
  // Connect with a client.

  async function clientDemo () {
    const client = new Client(credentials)
    await client.connect()
    const res = await client.query('with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1  as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on a.id = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;') 
    await client.end()
  }

  const clientResult = await clientDemo()
  console.log('Time with client: ' + clientResult.rows[0].now)

};
</code></pre>
<p>Report</p>
<pre><code>&lt;style&gt;
    td, th {
        padding: 5px;
        text-align: right;
    }
&lt;/style&gt;
&lt;table name=&quot;Data&quot;&gt;
    &lt;tr&gt;
        &lt;td class=&quot;title&quot; colspan=&quot;10&quot;&gt;DAILY STATE BALANCE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr class=&quot;cell-titles&quot;&gt;
        &lt;th&gt;STATE&lt;/th&gt;
        &lt;th&gt;CREDITS&lt;/th&gt;
        &lt;th&gt;ACTUAL_CASH&lt;/th&gt;
        &lt;th&gt;UNREVEALED&lt;/th&gt;
        &lt;th&gt;CUSTOMER_FUNDS&lt;/th&gt;
    &lt;/tr&gt;
    {{#each rows}}
        &lt;tr&gt;
            &lt;td&gt;{{{STATE}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_CREDITS}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_ACTUAL_CASH}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_UNREVEALED}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_CUSTOMER_FUNDS}}}&lt;/td&gt;
        &lt;/tr&gt;
    {{/each}}
&lt;/table&gt;</code></pre>
]]></description><link>https://forum.jsreport.net/topic/2472/after-argument-list-sandbox-js-16</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 21:59:01 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2472.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Jun 2022 13:27:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>Postgres report</p>
<pre><code>Render request 16 queued for execution and waiting for availible worker
info+7Starting rendering request 16 (user: admin)
info+3Rendering template { name: Daily_State_Balance(clone), recipe: html-to-xlsx, engine: handlebars, preview: true }
debug+4Data item not defined for this template.
debug+3Executing script dev11db-test (beforeRender)
error+10Error when processing render request 16 Error when evaluating custom script /Dev11/dev11db-test
missing ) after argument list sandbox.js:16
    const res = await client.query('with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1  as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on a.id = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;') 
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: missing ) after argument list
    at new Script (node:vm:100:7)
    at doCompileScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/createSandbox.js:224:14)
    at run (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/createSandbox.js:169:72)
    at WorkerReporter._runInSandbox (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/sandbox/runInSandbox.js:163:12)
    at WorkerReporter.runInSandbox (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:152:17)
    at async executeScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/executeScript.js:122:12)
    at async Scripts._runScript (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/worker.js:140:30)
    at async Scripts.handleBeforeRender (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-scripts/lib/worker.js:64:7)
    at async ListenerCollection.fire (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/shared/listenerCollection.js:157:21)
    at async beforeRender (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:25:5)
    at async WorkerReporter._render (/home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:146:7)
    at async /home/ubuntu/jsreportapp/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:179:19
    at async Domain.&lt;anonymous&gt; (/home/ubuntu/jsreportapp/node_modules/@jsreport/advanced-workers/lib/workerHandler.js:141:19)
error+0Rendering request 16 finished with error in 27 ms
</code></pre>
<p>DATA script</p>
<pre><code>async function afterRender (req, res) {
  const { Client } = require('pg')

  const credentials = {
    user: 'sddev',
    host: 'dev11-ro-database-01.************.us-east-2.rds.amazonaws.com',
    database: 'ats_whitelabel',
    password: '*************',
    port: 5432
  }
  // Connect with a client.

  async function clientDemo () {
    const client = new Client(credentials)
    await client.connect()
    const res = await client.query('with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1  as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on a.id = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;') 
    await client.end()
  }

  const clientResult = await clientDemo()
  console.log('Time with client: ' + clientResult.rows[0].now)

};
</code></pre>
<p>Report</p>
<pre><code>&lt;style&gt;
    td, th {
        padding: 5px;
        text-align: right;
    }
&lt;/style&gt;
&lt;table name=&quot;Data&quot;&gt;
    &lt;tr&gt;
        &lt;td class=&quot;title&quot; colspan=&quot;10&quot;&gt;DAILY STATE BALANCE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr class=&quot;cell-titles&quot;&gt;
        &lt;th&gt;STATE&lt;/th&gt;
        &lt;th&gt;CREDITS&lt;/th&gt;
        &lt;th&gt;ACTUAL_CASH&lt;/th&gt;
        &lt;th&gt;UNREVEALED&lt;/th&gt;
        &lt;th&gt;CUSTOMER_FUNDS&lt;/th&gt;
    &lt;/tr&gt;
    {{#each rows}}
        &lt;tr&gt;
            &lt;td&gt;{{{STATE}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_CREDITS}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_ACTUAL_CASH}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_UNREVEALED}}}&lt;/td&gt;
            &lt;td&gt;{{{STATE_CUSTOMER_FUNDS}}}&lt;/td&gt;
        &lt;/tr&gt;
    {{/each}}
&lt;/table&gt;</code></pre>
]]></description><link>https://forum.jsreport.net/post/10682</link><guid isPermaLink="true">https://forum.jsreport.net/post/10682</guid><dc:creator><![CDATA[djbrody]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>You have a syntax error in the script as the error explains. Check that line carefully.</p>
]]></description><link>https://forum.jsreport.net/post/10685</link><guid isPermaLink="true">https://forum.jsreport.net/post/10685</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>this SQL correct line</p>
<p><code>contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State,</code></p>
<p>But I guess the script does not like this what would be the option for jsreport?</p>
]]></description><link>https://forum.jsreport.net/post/10689</link><guid isPermaLink="true">https://forum.jsreport.net/post/10689</guid><dc:creator><![CDATA[djbrody]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Thu, 23 Jun 2022 18:08:23 GMT]]></title><description><![CDATA[<p>hi! the fix is not anything in particular related to jsreport or the jsreport script, it is more a problem with javascript strings.</p>
<p>as you know you can delimit a javascript string with either <code>'</code> or <code>&quot;</code>, however since your string is expected to contain SQL queries, then you are using <code>'</code> inside the string when this happens javascript gets confused, because it thinks you are trying to close the string, in this case, you have two options you either use template literals `string` or escape the <code>'</code> characters inside your string:</p>
<p>option 1:</p>
<p>`with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1  as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;'ContactDetail'-&gt;&gt;'address4' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on <a href="http://a.id" rel="nofollow">a.id</a> = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;`</p>
<p>option 2:</p>
<p><code>'with balances as ( select acco_id, ROUND(SUM(CASE WHEN wallet_type_id=1 and fund_type_id=1 THEN balance ELSE 0 END), 2) ACTUAL_CASH, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=11 THEN balance ELSE 0 END), 2) CREDITS, ROUND(SUM(CASE WHEN wallet_type_id=4 and fund_type_id=16 THEN balance ELSE 0 END), 2) UNREVEALED, current_date -1 as trans_date from betcatch.account_balances where brand_id = 3 group by 1 ) select contact_details::json-&gt;\'ContactDetail\'-&gt;&gt;\'address4\' as State, SUM(CREDITS) STATE_CREDITS, SUM(ACTUAL_CASH) STATE_ACTUAL_CASH, SUM(UNREVEALED) STATE_UNREVEALED, SUM((ACTUAL_CASH + UNREVEALED)) &quot;state_customer_funds&quot; from accounts a inner join balances b on a.id = b.acco_id where brand_id = 3 group by 1 by state ORDER BY 1;'</code></p>
<p>(note that now this part <code>\'ContactDetail\'-&gt;&gt;\'address4\'</code> is escaped)</p>
]]></description><link>https://forum.jsreport.net/post/10690</link><guid isPermaLink="true">https://forum.jsreport.net/post/10690</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Thu, 23 Jun 2022 18:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>Thanks for the help with sql</p>
<p>hit this but I know I run npm install -g pg</p>
<pre><code>Error when evaluating custom script /Dev11/dev11db-test
Unable to find module pg
The require calls:
require('pg')
require('/home/ubuntu/jsreportapp/pg')


(sandbox.js line 2:22)

  1 | async function afterRender (req, res) {
&gt; 2 |   const { Client } = require('pg')
    |                      ^
  3 |
  4 |   const credentials = {
  5 |     user: 'sddev',</code></pre>
]]></description><link>https://forum.jsreport.net/post/10691</link><guid isPermaLink="true">https://forum.jsreport.net/post/10691</guid><dc:creator><![CDATA[djbrody]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<blockquote>
<p>hit this but I know I run npm install -g pg</p>
</blockquote>
<p>you installed the <code>pg</code> module globally, however in order for the jsreport script to recognize such module it should be installed locally in your jsreport server project, so basically it needs to be part of the package.json of the jsreport server, you can go to the folder where your package.json is and execute <code>npm i pg --save</code></p>
]]></description><link>https://forum.jsreport.net/post/10692</link><guid isPermaLink="true">https://forum.jsreport.net/post/10692</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>Ok so update pg locally and restarted now have this error. This is the config for my production</p>
<pre><code>Report &quot;dev11_Daily_State_Balance&quot; render failed.

Connection terminated
Error: Connection terminated
    at Connection.&lt;anonymous&gt; (/home/ubuntu/jsreportapp/node_modules/pg/lib/client.js:132:36)
    at Object.onceWrapper (node:events:641:28)
    at Connection.emit (node:events:539:35)
    at Connection.emit (node:domain:537:15)
    at Socket.&lt;anonymous&gt; (/home/ubuntu/jsreportapp/node_modules/pg/lib/connection.js:57:12)
    at Socket.emit (node:events:527:28)
    at Socket.emit (node:domain:537:15)
    at TCP.&lt;anonymous&gt; (node:net:709:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)</code></pre>
]]></description><link>https://forum.jsreport.net/post/10693</link><guid isPermaLink="true">https://forum.jsreport.net/post/10693</guid><dc:creator><![CDATA[djbrody]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to after argument list sandbox.js:16 on Invalid Date]]></title><description><![CDATA[<p>this looks like an issue with the connection to postgres itself, have you tried running the code alone? i mean outside of jsreport, you can take all the code inside your <code>afterRender</code> function and put it in a file like <code>test-connection.js</code> inside your jsreport project, then start testing with <code>node test-connection.js</code>, if you hit the same error you should likely check the <a href="https://github.com/brianc/node-postgres" rel="nofollow">https://github.com/brianc/node-postgres</a> docs, perhaps there is something else that you are missing to configure in the connection options.</p>
]]></description><link>https://forum.jsreport.net/post/10694</link><guid isPermaLink="true">https://forum.jsreport.net/post/10694</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>