1

get_result_rows node.js error 5

Тема: get_result_rows node.js error 5

Hello, I need to get the reports with their respective data. I am working with node.js.
After reading, making tests and errors, I managed to obtain the answers, but not their data.
I will tell you the steps I have followed to achieve this.
1.- I look for the id of the vehicles by their name with the function core/search_items.
2.- I look for the id of the reports and the id of the template with the function core/search_items.
3.- I look for the reports with the function report/exec_report.
Here is my problem, it does not show me the data of the vehicles of those reports.
I read that I should execute the function report/get_result_rows, but it does not work for me, it generates error 5.
I'm confundant with the table index.

The result that I generate report/exec_reportd:

{ reportResult:
   { msgsRendered: 1,
     stats: [],
     tables: [ [Object], [Object], [Object] ],
     attachments: [] },
  reportLayer:
   { name: 'report unit_msgs',
     bounds: [ -33.5327339172, -70.8768463135, -33.4696273804, -70.7319946289 ],
     units: [ [Object] ] },

The code of the function report/get_result_rows

function resultRows () {
    var params = {
        "tableIndex":0,
        "indexFrom":0,
        "indexTo":0
    };
    request.post({
        url: URL + 'svc=report/get_result_rows',
        json: true,
        form: {
            sid: SID,
            params: JSON.stringify(params)
        }
    }, function (error, response, body) {
        console.log(body);
    });
}

Note: I occupy report/get_result_rows because all the tables are level 1.

2

get_result_rows node.js error 5

Re: get_result_rows node.js error 5

get_result_rows returns error 5 in three cases:

  • Session do not have executed report (e.g. exec_report was not called, or report/cleanup_result was called before get_result_rows call)
  • Report result do not have tables
  • There is no such table with specified tableIndex

But in your exec_report result I see:

tables: [ [Object], [Object], [Object] ],

So, we are getting error 5 not by two last cases.

Are you executing get_result_rows straight after exec_report and in the same session?

3

get_result_rows node.js error 5

Re: get_result_rows node.js error 5

Thanks Rual, just the problem was that in the function of exec_report it did not call the function get_result_rows.
Thaks so much for the orientation.