How to use script box in query report (on Frappe Cloud)

I need to use the query report on Frappe Cloud and am able to add a custom SQL script to the query field. However, I struggle to find any information how to make the Script text field work.
There is no mentioning of the script field in the docs (https://frappeframework.com/docs/user/en/desk/reports/query-report). I know that one can specify a .js-Script if self-hosting ERPnext. This is not possible if ERPnext is hosted by Frappe. It seems that this Script field aims to allow some degree of scripting even if hosted on Frappe Cloud. Does anyone know how to use the script box to customize the query report (for e.g. formating, additional calculations etc.)?

Did you find some solution.???

You have to use python script for the same.
Start with Something like this.

data = []
data = get_columns(filters), get_result(filters)

then define a function to add your columns for the report

def get_columns(filters):
    columns = []
    columns = [
            {"fieldname": "BOM", "label" : _("BOM"), "fieldtype": "Link", "options": "BOM", "width": 220},
            
            {"fieldname": "qty", "label" : _("Qty"), "fieldtype": "Float", "width": 80},
            {"fieldname": "uom", "label" : _("UOM"), "fieldtype": "Data", "width": 80},
             {"fieldname": "ratc", "label" : _("RateC"), "fieldtype": "Data", "width": 80},
            {"fieldname": "rate", "label" : _("Rate"), "fieldtype": "Currency", "width": 120},
            {"fieldname": "amount", "label" : _("Amount"), "fieldtype": "Currency", "width": 140}
        ]

    return columns

You should now have a function for getting the result
def get_result(filters):
table = []
return table

so the whole code should like this

def get_columns(filters):
    #Build your columns here
    return columns
def get_result(filters):        
    table = []
    #your logic to build the table
    return table
# Begin of execute    
data = []
data = get_columns(filters), get_result(filters)

For me this V13-How to default the filter value in Query reports is the starting point

1 Like