<script>
var getUrlParameter = function(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables.split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
rid = getUrlParameter("rid");
console.log(rid);
document.getElementById("RID#").innerHTML = rid;
<!---------------GET_TEMPORARY_TOKEN---------------------->
var appToken = ''
var realm = '' // demo.quickbase.com
var dbid = '' // table you want to query
var ticket = ''
var tempAuth = ''
var headers = {
'QB-Realm-Hostname': realm,
'QB-App-Token': appToken,
'Content-Type': 'application/json'
}
const xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', 'https://api.quickbase.com/v1/auth/temporary/' + dbid, false);
for (const key in headers) {
xmlHttp.setRequestHeader(key, headers[key]);
}
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === XMLHttpRequest.DONE) {
console.log(xmlHttp.responseText);
document.getElementById("AUTH#").innerHTML = xmlHttp.responseText;
ticket = JSON.parse(xmlHttp.responseText);
document.getElementById("VAR#").innerHTML = ticket.temporaryAuthorization;
tempAuth = "QB-TEMP-TOKEN " + ticket.temporaryAuthorization;
}
};
xmlHttp.withCredentials = true;
xmlHttp.send();
//tempAuth = "QB-TEMP-TOKEN " + ticket.temporaryAuthorization
<!---------------GET_DATA_FROM_FIELDS---------------------->
document.getElementById("PASS#").innerHTML = tempAuth;
headers = {
'QB-Realm-Hostname': realm,
'Authorization': tempAuth,
'Content-Type': 'application/json'
}
var body = {
"from": dbid,
"select": [237, 229, 253, 277, 313, 334, 254, 278, 314, 335, 255, 279, 315, 336, 256, 280, 316, 337, 257, 281, 317, 338, 258, 282, 318, 339, 259, 283, 319, 340, 260, 284, 320, 341, 261, 285, 321, 342, 262, 286, 322, 343, 263, 287, 323, 344, 264, 288, 324, 345, 265, 289, 325, 346, 266, 290, 326, 347, 267, 291, 327, 348, 268, 292, 328, 349, 269, 293, 329, 350, 270, 294, 330, 351, 271, 295, 331, 352, 272, 296, 332, 353, 273, 297, 333, 354, 274, 362, 372, 382, 275, 363, 373, 383, 432],
"where": "{3.EX." + rid + "}"
}
const xmlHttp2 = new XMLHttpRequest();
xmlHttp2.open('POST', 'https://api.quickbase.com/v1/records/query', false);
for (const key in headers) {
xmlHttp2.setRequestHeader(key, headers[key]);
}
xmlHttp2.onreadystatechange = function() {
if (xmlHttp2.readyState === XMLHttpRequest.DONE) {
console.log(xmlHttp2.responseText);
document.getElementById("Q#").innerHTML = xmlHttp2.responseText;
}
};
xmlHttp2.send(JSON.stringify(body));
</script>
There were other changes that needed to be done as well I think. I made so many little changes here and there. Some may not have been needed because in the end it was just the 2 lines that were running async when it was better they were synced.
You can try that and compare it to what you have and see the changes and also make sure it works. Brad might even have a better one set up. I see we both posted at the same time lol.