NS = {
+ timeout : 10,
rungrab : function(id)
{
var timeout = 10;
var frameload = function()
{
- var ifd = ifr.contentWindow.document;
- var chk = ifd.getElementById('lines');
- if (!ifd.getElementById('rptdataarea') || !ifr.contentWindow.reportTable
- ) {
- console.log('report not ready?');
- window.setTimeout(frameload,1000);
- return;
-
- }
-
-
- console.log('report ready?');
-
- if (chk.value !='T') {
- chk.value= 'T';
- ifd.forms[0].daterange.value = 'CUSTOM';
-
- ifd.getElementById('date1').value = '1/1/2008';
- ifd.getElementById('date2').value = '1/1/2013';
-
- ifd.getElementById('footerform').submit();
-
- return;
- }
-
- if ( ifr.contentWindow.reportTable.oContentProvider.bRequestPending
- || !ifr.contentWindow.reportTable.isInLoadedState()) {
- console.log('report not ready?');
- timeout--;
- if (timeout < 0) {
- console.log(
- JSON.stringify ({
- requesturl : '',
- method: 'nsdownloadpage',
- filename : NS.id + '.csv',
- headers : '',
- contentType: '',
- data: []
- }));
- return;
-
-
- }
-
- window.setTimeout(frameload,1000);
-
- return;
-
- }
-
-
+
- console.log("TRY downloading!");
- var ar = ifd.getElementById('footerform').elements;
- var data= {};
- for(var i =0; i < ar.length; i++) {
- var e = ar[i];
- data[e.name] = e.value;
- }
- console.log(data);
- console.log(ifr.contentWindow.reportTable.getTotalRowCount());
- NS.downloaddata(
- 'https://system.netsuite.com/app/reporting/reportrunner.nl',
- {
- id: data.id,
- reportaction: 'exportcsv',
- apptype: 'html',
- visibleranges: '0,' + ifr.contentWindow.reportTable.getTotalRowCount()
- }
-
- );
}
console.log("document.location" + document.location);
if ( reportTable.oContentProvider.bRequestPending
|| !reportTable.isInLoadedState()) {
console.log('report not ready?');
- timeout--;
- if (timeout < 0) {
+ NS.timeout--;
+ if (NS.timeout < 0) {
console.log('SENDING EMTPY..?');
console.log(
JSON.stringify ({
}
- window.setTimeout(frameload,1000);
+ window.setTimeout(rungrab,1000);
return;
console.log("got rungrab");
+
+ console.log("TRY downloading!");
+
+ var ar = document.getElementById('footerform').elements;
+ var data= {};
+ for(var i =0; i < ar.length; i++) {
+ var e = ar[i];
+ data[e.name] = e.value;
+ }
+ console.log(data);
+ console.log(document.reportTable.getTotalRowCount());
+ NS.downloaddata(
+ 'https://system.netsuite.com/app/reporting/reportrunner.nl',
+ {
+ id: data.id,
+ reportaction: 'exportcsv',
+ apptype: 'html',
+ visibleranges: '0,' + document.reportTable.getTotalRowCount()
+ }
+
+ );
+
+
+
return;