Skip to main content
Question

create parent record on loading of child form


Hi

I am loading a quickbase form from another application. The application will pass some parameters to quickbase form. While loading the form i want to catch these parameters in quickbase
and need to create an entry in another table. After creating the entry i want to load the qb form.

How can be achieved this?

Thanks
This topic has been closed for replies.

Do you mean to pass parameters via a query string in a URL?

Application  -> Dashboard - Settings - variables
you should see the below variables 
/iol
/script
appID
iol
script
These are the java script variables that can be used in the formula fields in any of your table's fields.

Step 2: 
Create formula field
Type - Formula Text
formula - [iol] & "custom.js" & [/iol]

Step 3:
Add the field from step 2 into the form (this is the form where the application will receive parameters)

Step 4:
Create a custom page "custom.js" in application pages and add the below script
1. read the params
2. create the parent record
3. from the response take the record id and reload the form by adding the is param using the fid of the related parent field.  




Below is the partial code that helps

 function readParams() {
var params = {};

var locationObj = window.parent.location.search;
if(!locationObj){
locationObj = window.location.search;
}
if (locationObj) {
var parts = window.parent.location.search.substring(1).split('&');

for (var i = 0; i < parts.length; i++) {
var nv = parts.split('=');
if (!nv[0])
continue;
params[nv[0]] = nv[1] || true;
params[nv[0]] = decodeURIComponent(params[nv[0]]);
}
}
console.log(JSON.stringify(params));
return params;
};

function createRecordAndReload(){
var params = readParams();
//the params var will have all the data from the url

//refer to https://help.quickbase.com/api-guide/index.html#add_record.html%3FTocPath%3DQuickBase%2520API%2520Ca...
//make an ajax call using api API_AddRecord and with above params create parent record
addParentRecord(params);

//on success of the above ajax call reload the window adding a new param with fid of the related parent field 
//NOT:
//when the form loads it will trigger the same script but this time you shouldn't run the above call to create a record. when you see the related parent field id don't execute the above ajax call.
reloadPage();
}

function addParentRecord(params){
}

function reloadPage(){
}

createRecordAndReload();

  • Registered
  • March 31, 2017
You can do this with native quickbase API, no need for the IOL or script (hopefully).

Lookup the API guide for "AddRecord" and "DoSaveAdd".

QB will pass what called a "MasterRecord" variable for the child creation.  Its a tricky work around, but might work for you.  It would take some investigating still.

****
On a different note, any chances you can make the parent AFTER the child record is made, then retroactively connect to the parent?  This can also be done with either some script or a button push.

Just some ideas...

>no need for the IOL or script (hopefully).

It is an anti-pattern to suggest there is no need for using IOL or script. Web pages run on JavaScript and there is no alternative (vbscript was the only alternative and it lost the game to JavaScript over a decade ago). There is no well formed problem that script cannot solve and setting up IOL (or other script injection technique) should be the first thing you do to any application.

Why monkey around with superfluous formula fields to do repeated lookup and summary fields and create imaginary relationships between tables only to encounter further limitation or additional pain maintain these constructs?

Accept JavaScript into your heart and all your QuickBase problems will evaporate.