<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Record with RID</title>
</head>
<style>
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
display: block;
margin-left: auto;
margin-right: auto;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
<script src = '
https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'> </script>
<script>
function run() {
const realm = window.location.hostname.substring(0, window.location.hostname.indexOf("."));
const urlParams = new URLSearchParams(window.location.search);
const dbid = urlParams.get('dbid');
const mode = urlParams.get('mode');
statusStream('Creating a blank record...');
// Create the payload to upsert a blank record into the provided table
const payload = {
"to": dbid,
"data": [
{}
]
};
$.ajax({
url: '
https://api.quickbase.com/v1/records',
headers: {
'QB-Realm-Hostname': realm,
'Authorization': `QB-TEMP-TOKEN ` // EOTI access doesn't require a token
},
method: 'POST',
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload),
success: function (response) {
statusStream('Redirecting to the newly created record...');
const rid = response.metadata.createdRecordIds[0];
window.location.href = `
https://${realm}.quickbase.com/db/${dbid}?a=${mode}&rid=${rid}`;
}
});
}
function statusStream(message){
// Add message to the on screen status stream
document.getElementById('statusLog').insertAdjacentHTML("beforeend", `${message}<br>`);
}
</script>
<body onload="run()" style="text-align:center">
<h2>Processing...</h2>
<div class="loader" id="loader"></div>
<br><br>
<div id="statusLog" style="font-size:20px"></div>
</body>
</html>
<!--
These code samples are provided "AS IS" without any warranties of any kind and is not supported by Quickbase teams.
You are responsible for the security and maintenance of any third-party code inside of your application.
Any reliance on Quickbase functions, HTML, CSS or other document-object-model (DOM) elements should be considered unstable and may change at any time, without notice.
Builders should not reference or rely on common libraries hosted by Quickbase (such as jQuery or Angular) as these may change at any time.
Customers should reference their own hosted libraries or from 3rd-party resources that they can trust and maintain
-->