Skip to content

Instantly share code, notes, and snippets.

@kevinseelbach
Last active December 15, 2015 04:59
Show Gist options
  • Save kevinseelbach/5205612 to your computer and use it in GitHub Desktop.
Save kevinseelbach/5205612 to your computer and use it in GitHub Desktop.
Get Report Data javascript help
var listToGet = [{
url: 'https://example.quickbase.com/db/dbid?a=q&qid=##',
name: 'jobs'
},
{
url: 'https://example.quickbase.com/db/dbid?a=q&qid=##',
name: 'messages',
}]
getReportData = function(reports) {
//Get reports in array of objects with report.url and report.type property
for (var i = reports.length - 1; i >= 0; i--) {
listOfStuff[reports[i]['name']] = [];
var response = '';
$.ajax({
url: reports[i]['url'],
type: 'GET',
dataType: 'xml',
async: false,
success: function(xml) {
response = xml;
}
});
$(response).find('record').each(function() {
var row = {};
$(this).children().each(function() {
var tagName=S(this.tagName).camelize().s;
var val=$(this).text();
if (tagName.indexOf('date') >= 0) {
var d = new Date(0);
d.setUTCSeconds(Math.round(val/1000));
val = $.datepicker.formatDate('yy-mm-dd', d);
}
else if (tagName == 'Deposited') {
val = String(Math.round(val * 100) + '%');
}
row[tagName] = val;
});
listOfStuff[reports[i]['name']].push(row);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment