Calculation In Report



  • How to make complex reports like attendance report, where I need to calculate and add a custom field named "Status" in which user will be marked as P/A etc. according to their punch timings.

    I am fetching data using this code :-

    function beforeRender(request, response, done) {
        con.connect(function(err) {
            if (err) throw err;
            con.query("select * from attendance_report2 where emp_id = '710101'", function(err, result, fields) {
                if (err) throw err;
                Object.assign(request.data, {
                    employees: result
                })
                // return request.data;
                done();
            });
        });
    }
    


  • @Kshitiz-Mittal
    You can assign any valid JSON to request.data, so you can transform your query result and add new properties, alot of our reports are run by querying multiple datasets and then using JS to join and transform the data as needed, we primarily use HTTP OData requests to retrieve data but some reports are direct SQL using the 'mssql' NPM library

    Hope that helps


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.