Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
Yes it is possible in a variety of ways. Here is one way that uses a technique to jam the relevant JavaScript into an onclick handler of an <a> element synthesized using a Rich Text Formula Field.
Here is a screenshot of the Formula Definition being entered:
This is one big text string with hard-coded values for dbidTable, qid and output. You would need to changes these values to suit your needs or modify the formula to pass in field values from the record.
There are three types of quotes used in this formula and you need to take great care not to mess any of them up:
(1) Double quotes (ie ") are used at the beginning and end a double quotes are used in the formula language to delineate text strings.
(2) Single quotes (ie ') are used to deliniate the start and end of the onclick attribute of the <a> element.
(3) Backtick quotes (ie ') are used in the body of the JavaScript code where normally you might use single or double quotes and also where string interpolation is being performed (their real use).
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=700
I just noticed that this is the 700th record entered into the Pastie Database so I am going to celebrate with Kool & The Gang!
"<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= 'bgcwm2m4g';
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>"
Here is a screenshot of the Formula Definition being entered:
This is one big text string with hard-coded values for dbidTable, qid and output. You would need to changes these values to suit your needs or modify the formula to pass in field values from the record.
There are three types of quotes used in this formula and you need to take great care not to mess any of them up:
(1) Double quotes (ie ") are used at the beginning and end a double quotes are used in the formula language to delineate text strings.
(2) Single quotes (ie ') are used to deliniate the start and end of the onclick attribute of the <a> element.
(3) Backtick quotes (ie ') are used in the body of the JavaScript code where normally you might use single or double quotes and also where string interpolation is being performed (their real use).
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=700
I just noticed that this is the 700th record entered into the Pastie Database so I am going to celebrate with Kool & The Gang!
- JasonJohnson26 years agoQrew CadetThis is almost perfect for my need. I want to from a form in one table print a report from another table but to add filtering so that it is only records related to that record being saved.
I attempted to do this by changing my report to add add an ask user filter then added this into the script
var srt = '&nv=1&v0=';
var wtr = '[Record ID#]';
Then I changed the script on the URL to
var url = '${dbidTable}?a=q&qid=${qid}&${srt}&${wtr}&opts=csv';
I get an export but it is 4900+ lines of code, definitely not the report.