How do you use the optional parameters for custom script reports?

A developer can optionally return a few paramters like message, chart, report_summary, skip_total_rows.

I am trying to figure out how i can return and reuse the parameters from a custom report in a jinja template.

Can you say more about what you’re trying to do? I’m not really following.

Hi @peterg, i am trying to pass calculated values from the report (report summary) to the jinja template so i can access it from the html template of the report.


Basically trying to populate the summary table in the pdf with the values from the report summary. Also is there anyway to pass the values from the report to the template.

When you say HTML, do you mean a Report Print Format?

https://frappeframework.com/docs/v13/user/en/guides/reports-and-printing/print-format-for-reports

This is a very old implementation, long overdue for an update. I don’t think much is exported to the jinja context here. You might scrape through the report variable to see if anything relevant is being sent over.

Yeah, i am trying to pass some values to the report print format. How can i print the variables?i have been trying a while to print the value of the report variables but no luck. Also what values are stores in the data object?

I’m really not familiar with report print formats, so I’m only guessing here. I would assume that the data object is the same as the data you pass to the output of the script report. To browse report, you might just convert it all to json and output it as a string. Something like

{{ report|json }}

should work.

Uncaught ReferenceError: json is not defined

thanks @peterg, I figured it out the report print format uses the John Resig - JavaScript Micro-Templating which is not jinja so i had to use console.log(report); to see the report objects. I used that to get the value from the report summary.

1 Like