BillBurrrell
4 years agoQrew Member
Download Report and Mark entries as downloaded
So I'm trying to setup a system that gets me a file of a set of entries from one table. I need it as a .xlsx, but I can convert the file from a .csv easy enough. I also need to mark all entries that are exported as exported. I'm hoping to get do everything from a single click, up to the export anyway (the file conversion can be done manually).
So I'm currently looking at using a URL button to launch a code page. I'm using a report to pass the fields/data to be used and exported. I've managed to get the URL button to work. But I'm struggling with setting up the code page, mostly since I don't have much experience with Javascript. This has been enough to get the button to function for the download, but I'm having a hard time figuring out the next steps. I've got this far mostly by taking a large number of examples from others on here and playing around a bunch.
I'm assuming I'll have to use the DoQueryCount and EditRecord APIs in a loop of sorts to update each record. I've got a simple checkbox, [Exported], for tracking the files that have been exported. Any advice/suggestions would be appreciated.
------------------------------
Bill Burrrell
------------------------------
So I'm currently looking at using a URL button to launch a code page. I'm using a report to pass the fields/data to be used and exported. I've managed to get the URL button to work. But I'm struggling with setting up the code page, mostly since I don't have much experience with Javascript. This has been enough to get the button to function for the download, but I'm having a hard time figuring out the next steps. I've got this far mostly by taking a large number of examples from others on here and playing around a bunch.
I'm assuming I'll have to use the DoQueryCount and EditRecord APIs in a loop of sorts to update each record. I've got a simple checkbox, [Exported], for tracking the files that have been exported. Any advice/suggestions would be appreciated.
//URL button code
var text GetReport = "?a=q&qid=10";
var text DownloadReport = "&opts=csv";
URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=42" & // code page
"&url=" & URLEncode(URLRoot() & "db/" & Dbid() & $GetReport) & //passed to code page for marking records downloaded
"&rdrurl=" & URLEncode(URLRoot() & "db/" & Dbid() & $GetReport & $DownloadReport)//passed for final redirect
//Code Page
<!DOCTYPE html>
<html>
<head>
<script>
var urlParams = new URLSearchParams(window.location.search);
var url = urlParams.get('url');
var rdrurl = urlParams.get('rdrurl');
window.open(url,'Print');
window.location.href = rdrurl;
</script>
</head>
</html>
------------------------------
Bill Burrrell
------------------------------