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

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 - #2 by gsarunk is the starting point

1 Like