[development - script report] [solved] How to send addition information in script report from python to HTML template

I am developing a script report in version 12 to send statements to clients based on the general ledger report.

Currently, the execute function returns only columns and results

def execute(filters=None):
         ...
    return columns, res

I need to send additional information

def execute(filters=None):
         ...
    data_to_be_printed = get_customer_details(filters.party)
         ...
    return columns, res, None, None, data_to_be_printed

It appears as if the last parameter will appear as “data_to_be_printed”. The following posts allude to this.

The resulting JSON is indeed showing the field

{
   "JSON":{
      "message":{
         "result":[
            {
               .....
            },
         ],
         "columns":[
            {
               .....
            },
         ],
         "message":"hello",
         "chart":"",
         "data_to_be_printed": "Data 1",
         "status":null,
         "execution_time":0,
         "add_total_row":0
      }

In my html report, I tried to print, without success.
I even tried setting and accessing the variable as an array, but it appears I cannot access the “data_to_be_printed” in the HTML report.

<div>
[[ {%= this.data_to_be_printed %} ]]<br>
[[ {%= data_to_be_printed %} ]]<br>
</div>

Any ideas where I could be going wrong?

I hope you have find the answer you were looking for.

Well I have same scenario where I’m using the “data_to_be_printed” in response but the parameter is not getting print on page. Can you please guides me.

Hi, I have found an workaround, not sure whether it is a correct implementation or not.

{%= report.raw_data.data_to_be_printed %}

Can anyone please verify this implementation?

2 Likes

I can confirm this works. Thank you

If data_to_be_printed is a dictionary (dict), how can I handle it? This
doesn’t work."