Forum Discussion
QuickBaseCoachD
8 years agoQrew Captain
So you cannot actually populate a checkbox field when opening the record to edit.
The only option would be to actually have that checkbox set to checked under the covers and then display the record in Edit mode.
The subtle difference is that when the user clicks the button, that checkbox will be checked, regardless if they choose to back out of the edit process and not actually save the record.
The code would be in two steps like this, using formula variables for each step.
var Checkbox= URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=xxxxxxx"
& "&_fid_155=1;
var Edit = URLRoot() & "db/" & Dbid() & "?a=er&key="&[Record ID#]&"&dfid=11";
$Checkbox
& "&rdr=" & URlEncode($Edit)
If you have application tokens set to be required you will need to supply that line
& "&apptoken=xxxxxxx"
or else disable them on the Settings in App properties and then you don't need that line.
The only option would be to actually have that checkbox set to checked under the covers and then display the record in Edit mode.
The subtle difference is that when the user clicks the button, that checkbox will be checked, regardless if they choose to back out of the edit process and not actually save the record.
The code would be in two steps like this, using formula variables for each step.
var Checkbox= URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=xxxxxxx"
& "&_fid_155=1;
var Edit = URLRoot() & "db/" & Dbid() & "?a=er&key="&[Record ID#]&"&dfid=11";
$Checkbox
& "&rdr=" & URlEncode($Edit)
If you have application tokens set to be required you will need to supply that line
& "&apptoken=xxxxxxx"
or else disable them on the Settings in App properties and then you don't need that line.
- _anomDiebolt_8 years agoQrew Elite>So you cannot actually populate a checkbox field when opening the record to edit.
It is worth noting that jotform allows you to do this through passing query string parameters:
https://www.jotform.com/help/71-Prepopulating-Fields-to-Your-JotForm-via-URL-Parameters
It would not be that hard to mimic this using the IOL technique.
Curiously QuickBase does allow you to do this for new records:
?a=nwr&_fid_6=foo&_fid_7=bar - QuickBaseCoachD8 years agoQrew CaptainRe: "Curiously QuickBase does allow you to do this for new records:"
It must be because there is an API for API_GenAddRecordForm (which must be what happens when the short form of a=nwr is used), but there is no API for "API_EditRecordForm" - ie that does not exist as an API.
- _anomDiebolt_8 years agoQrew EliteBut this is easy to do with script and IOL:
Here is a screenshot of me manually applying a three line scriptvar urlParams = new URLSearchParams(window.location.search);
_fid_6.value = urlParams.get('_fid_6');
_fid_7.value = urlParams.get('_fid_7');
So the IOL module.js code page would be this simple script:(function(){
var querystring=document.location.search;
if(/a=er/i.test(querystring)) {
var urlParams = new URLSearchParams(window.location.search);
_fid_6.value = urlParams.get('_fid_6');
_fid_7.value = urlParams.get('_fid_7');
}
})();
This is actually a perfect example of my JavaScript rant yesterday which was probably over most user's heads but is simple to understand in this instance.
JavaScript keeps getting better every day. Now there is (1) a new object available named URLSearchParams that will allow you to manipulate the URL's query parameters and (2) the browser automatically creates globals for all element ids in the page (ie _fid_6 and _fid_7).
You will not see URLSearchParams anywhere in QuickBase's code base but you will find various legacy code fragments that does the same thing. It isn't QuickBase's fault - every software company experiences this problem as the technology is changing too fast for even senior developers to keep up. Quite frankly I would be surprised if many QuickBase developers even know about these two particular features. Except that cute one - she seems like she knows her stuff. - _anomDiebolt_8 years agoQrew EliteOkay I just add this to the Pastie database:
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=600
It is worth noting two things:
(1) I have two statements in my code that sort of do the same general thing (manipulate the query string) - one old school and one new school:
var querystring=document.location.search;
var urlParams = new URLSearchParams(window.location.search);
This precisely how legacy code builds up. It happens to everyone. And no I am not going to change anything because this is throw away code.
(2) Well we reached 600 pasties today. To celebrate I am going slack off for the rest of the month and binge watch Silicon Valley reruns while checking every episode with TvTropes (http://tvtropes.org/pmwiki/pmwiki.php/Series/SiliconValley).