Forum Discussion

JasonJohnson2's avatar
JasonJohnson2
Qrew Cadet
6 years ago

Save as a spreadsheet of a report from a table from the form of another table.

I found a post similar that allows a save a spreadsheet from a button and the code is from Dan Diebolt (thanks Dan). I need to have the button in a form from a Projects table and save a report from a billing table. The code as is will save the report but not filtered to the specific project. Every variation I use to insert the record id#/ related project to filter with code fails. Either the button does nothing or it saves 7000 lines of code from QuickBase. I did submit to product feedback to make Automations to perform a save as spreadsheet function, go out and vote for it. (Automation for Save as Spreadsheet)

Yes I can teach the users to go to a report in a table and download but a button in the project would be so much better.

Any thoughts on how to add the filtering?
"<a href=# class='Vibrant Success' onclick='
function download(filename, content) {
  var blob = new Blob([content]);
  var a = document.createElement('a');
  a.href = window.URL.createObjectURL(blob); 
  a.download = filename;
  a.style.display = 'none';
  document.body.appendChild(a);
  a.click();
}

var dbidTable= 'dbidTable';
var qid = '1';
var output = 'output.csv';
var url = '${dbidTable}?a=q&qid=${qid}&opts=csv';
$.get(url, function(csv) {
  download('${output}', csv);
});
'>Download</a>"
  • AustinK's avatar
    AustinK
    Qrew Commander
    You should be able to add a line like this to the url and possibly end up where you want. You might have to check into https://help.quickbase.com/api-guide/do_query.html#queryOperators if you have not used the query operators that much. You would probably want to use CT in this case to compare against a specific value.

    &query=({'59'.XEX.'1'}AND{'9'.XEX.''})

    If this is a table report(it doesn't show for summary reports) go to the report you want and set it up the way you want, even as far as selecting the record id via a filter. Then view the report and click "More > Show Expanded URL For This Report" and it will show you what query it would expect to show that report.