Create a script report

In this example we will create a small script type report to see the characteristics of the system.

First add a new report from the options, select the script type and press set to view the editor. Remember when you add the new report to set all the parameters in order to view correctly.

--create filter interface






--create report grid





First of all, inside the interface script we insert all the commands to create the search filters and the columns that will be used to display the data.

The following rows, on the other hand, will be inserted into the processing script. While the interface script is launched only once, the processing script is performed every time we press the process button.

startdate = filtertable.getvalue("START")

enddate = filtertable.getvalue("END")

-- I do a basic search on a range of dates

iday = tostring(utility.dateday(startdate))

imonth = tostring(utility.datemonth(startdate))

iyear = tostring(utility.dateyear(startdate))

fday = utility.dateday(enddate)

fmonth = utility.datemonth(enddate)

fyear = utility.dateyear(endadate)

First, we recover the data values from the filtered table and prepare them for use in the search.

sql = "SELECT * FROM invoices WHERE eli=0 AND year(date) >=" .. iyear .. " AND month(date) >=" .. imonth .. " AND day(date) >=" .. iday

sql = sql .. " AND year(date) <=" .. fyear .. " AND month(date) <=" .. fmonth .. " AND day(date) <=" .. fday

-- I recover the remaining filters

rowcustomer = filtertable.getvalue("CUSTOMER")

if rowcustomer ~= nil then

sql = sql .. " AND gguid_name='" .. rowcustomer.getvalue("gguid") .. "'"


We prepare the sql string to perform the search by checking if a customer has been selected from the filter table. If yes we add it to the sql string for each search.


table_rows= database.getsql(sql)

rows = table_rows.getrows()

for i = 1,table_rows.countrows() do


row = reporttable.adddatarow()




We perform the search and begin to compile the report table with the values found.