Issue with exporting data from custom connector
When attempting to export the data from a custom connector via the data process section and checking the box "Create/Update Dataset" I am able to do so up until my second loop. I successfully export data to Domo when I don't include the second for loop in the datagrid build below and am not sure why that is the case. When I do add the second for loop I end up getting redirected to the following page: https://api.domo.com/Error%20adding%20data%20to%20stream%20664.%20ApiData%20response%20400
httprequest.addHeader(
'Authorization',
'Bearer ' + metadata.account.accesstoken
);
httprequest.addHeader('Accept', 'application/json');
var count_query = encodeURIComponent('select count(*) from bill');
var count_res = httprequest.get(
'https://quickbooks.api.intuit.com/v3/company/123146138190659/query?query=' +
count_query
);
var total_count = JSON.parse(count_res).QueryResponse.totalCount;
//DOMO.log('total count ' + total_count);
var total_pages = Math.ceil(total_count / 1000);
var bills = [];
for (var i = 0; i < total_pages; i++) {
var startposition;
if (i == 1) {
startposition = 1;
} else {
startposition = i * 1000;
}
var bill_query = encodeURIComponent(
'select * from bill startposition ' + startposition + ' maxresults 1000'
);
var res = httprequest.get(
'https://quickbooks.api.intuit.com/v3/company/123146138190659/query?query=' +
bill_query
);
var me = JSON.parse(res);
bills = bills.concat(me.QueryResponse.Bill);
}
//DOMO.log('res: ' + count_res);
//DOMO.log('res: ' + res);
//DOMO.log(me.QueryResponse.totalCount);
//DOMO.log(me.QueryResponse.maxResults);
//DOMO.log(bills.length);
//DOMO.log('me: ' + me.QueryResponse.Bill);
//DOMO.log('metadata.reportname: ' + metadata.report);
datagrid.addColumn('DocNumber', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('SyncToken', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('domain', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('APAccountRef_name', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('APAccountRef_value', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('VendorRef_name', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('VendorRef_value', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('TxnDate', datagrid.DATA_TYPE_DATE);
datagrid.addColumn('TotalAmt', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('CurrencyRef_name', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('CurrencyRef_value', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('PrivateNote', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('DueDate', datagrid.DATA_TYPE_DATE);
datagrid.addColumn('sparse', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('LineDetailType', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('LineAmount', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('LineId', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('TaxCodeRef_value', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('AccountRef_name', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('AccountRef_value', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('BillableStatus', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('Description', datagrid.DATA_TYPE_STRING);
datagrid.addColumn('Balance', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('Id', datagrid.DATA_TYPE_DOUBLE);
datagrid.addColumn('MetaData_CreateTime', datagrid.DATA_TYPE_DATETIME);
datagrid.addColumn('MetaData_LastUpdatedTime', datagrid.DATA_TYPE_DATETIME);
var data = bills;
for (var i = 0; i < data.length; i++) {
datagrid.addCell(data[i].DocNumber);
datagrid.addCell(data[i].SyncToken);
datagrid.addCell(data[i].domain);
datagrid.addCell(data[i].APAccountRef.name);
datagrid.addCell(data[i].APAccountRef.value);
datagrid.addCell(data[i].VendorRef.name);
datagrid.addCell(data[i].VendorRef.value);
datagrid.addCell(data[i].TxnDate);
datagrid.addCell(data[i].TotalAmt);
datagrid.addCell(data[i].CurrencyRef.name);
datagrid.addCell(data[i].CurrencyRef.value);
datagrid.addCell(data[i].PrivateNote);
datagrid.addCell(data[i].DueDate);
datagrid.addCell(data[i].sparse);
for (var j = 0; j < data[i].Line.length; j++){
datagrid.addCell(data[i].Line[j].DetailType);
datagrid.addCell(data[i].Line[j].Amount);
datagrid.addCell(data[i].Line[j].Id);
datagrid.addCell(data[i].Line[j].AccountBasedExpenseLineDetail.TaxCodeRef.value);
datagrid.addCell(data[i].Line[j].AccountBasedExpenseLineDetail.AccountRef.name);
datagrid.addCell(data[i].Line[j].AccountBasedExpenseLineDetail.AccountRef.value);
datagrid.addCell(data[i].Line[j].AccountBasedExpenseLineDetail.BillableStatus);
datagrid.addCell(data[i].Line[j].Description);
}
datagrid.addCell(data[i].Balance);
datagrid.addCell(data[i].Id);
datagrid.addCell(data[i].MetaData.CreateTime);
datagrid.addCell(data[i].MetaData.LastUpdatedTime);
datagrid.endRow();
}
Comments
-
Hi there,
So I can better understand the structure of the data array, can you please paste the following two lines of code underneath var data = bills; and send through the response
DOMO.log(data[0]);
DOMO.log(data[1]);Make sure to cover up/draw over any sensitive information
Cheers
Eric
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 58 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive