Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
>My understanding is that gReqAppDBID gets the table id of the current table.
Wrong - gReqAppDBID is the application dbid.
I have no idea what use QuickBase developers intended for the global variable gReqAppDBID. However, it appears to be consistently set the the dbid of the application (not a table dbid). Global variables are actually a bad idea and I am sure they will be purged from the product (as they are on mobile site). However, so long is QuickBase uses them there is no reason not to avail yourself of them for the time being as they can shorten the length of your code. This isn't just a pedantic point as there are other global variables that have the same value and I don't know what they are used for either:
https://login.quickbase.com/db/6ewwzuuj?a=dbpage&pageid=6
https://login.quickbase.com/db/9kaw8phg?a=dbpage&pageid=6
https://login.quickbase.com/db/6ewwzuuj?a=dbpage&pageid=6
If you are injecting JavaScript into a QuickBase authored page your code should be placed in what is called a IIFE (Immediately Invoked Function Expression):
The convention I use in writing scipt is to use the variable dbid to hold the application dbid and dbidTable to hold the dbid for a table named Table.
Along with some other changes I would write you code like this:
Wrong - gReqAppDBID is the application dbid.
I have no idea what use QuickBase developers intended for the global variable gReqAppDBID. However, it appears to be consistently set the the dbid of the application (not a table dbid). Global variables are actually a bad idea and I am sure they will be purged from the product (as they are on mobile site). However, so long is QuickBase uses them there is no reason not to avail yourself of them for the time being as they can shorten the length of your code. This isn't just a pedantic point as there are other global variables that have the same value and I don't know what they are used for either:
var gParentDBID = "bgcwm2m3z";I use the global variable gReqAppDBID in addressing a code page in an application. It turns out that you can address the same code page using either the application or table dbid. As I idicated previously, all of these URL point to the same code page:
var gReqAppDBID = "bgcwm2m3z";
https://login.quickbase.com/db/6ewwzuuj?a=dbpage&pageid=6
https://login.quickbase.com/db/9kaw8phg?a=dbpage&pageid=6
https://login.quickbase.com/db/6ewwzuuj?a=dbpage&pageid=6
If you are injecting JavaScript into a QuickBase authored page your code should be placed in what is called a IIFE (Immediately Invoked Function Expression):
(function(){This is to prevent variables in your code from interfering with QuickBase's variables. Its their page so we can stomp on variable names they may have chosen. So your code should look like this:
//your code here
})();
(function(){
var apptoken = "cci99s..............tqtfq";
$.ajaxSetup({data: {apptoken: apptoken}});
var description= prompt("Enter a brief description of the work done in this session: ", "");
var dbidTable = "bnqepesti";
var promise = $.get(dbidTable, {
act: "API_EditRecord",
rid: QBU_rid,
_fid_20: description,
_fid 6: "Out"
});
$.when(promise).then(function(){
document.location.href = dbidTable + "?a=dr&rid=" + QBU_rid;
});
})();
The convention I use in writing scipt is to use the variable dbid to hold the application dbid and dbidTable to hold the dbid for a table named Table.
Along with some other changes I would write you code like this:
(function(){
var dbid = "applicaton dbid";
var dbidTable = table dbid
var apptoken = "application token";
$.ajaxSetup({data: {apptoken: apptoken}});
var description= prompt("Enter a brief description of the work done in this session: ", "");
var promise = $.get(dbidTable, {
act: "API_EditRecord",
rid: QBU_rid,
_fid_20: description,
_fid 6: "Out"
}).then(function(xml) {
console.dirxml(xml);
document.location.href = dbidTable + "?a=dr&rid=" + QBU_rid;
});
})();