Forum Discussion
Can you not use the same code page approach? Have your button save the record and use the %%rid%% to pass in a parameter like &rid=%%rid%%, then in your code page grab the parameter from the URL and redirect the user back to the page after a setTimeout()
------------------------------
Chayce Duncan
------------------------------
- MikeTamoush10 months agoQrew Commander
That probably would work if I knew Javascript. As it is, all I can try to do is modify the existing code page which I have tried and failed miserably. Turns out you can't really just guess your way through a programming language :)
------------------------------
Mike Tamoush
------------------------------- MikeTamoush10 months agoQrew Commander
Actually that wont work. The problem is I am not on the parent record when it is 'saved'.
I am on a grandparent (though, at the time of the button push, it is not a parent or grandparent, it is a single record). I push a button and it runs the AddRecord API, adding a child. I want to delay, and then land on this child. I would need to somehow pass the RID of the new child.&disprec=1 performs some sort of magic that auto displays the newly created record. I would somehow need to know what magic it performs, and pass that magic into the code page.
Though it did just dawn on me, i can look up the max record id in the child table, and navigate to 1 more than that.....if I can figure out how to pass that +1 record ID to the code page....ill try it.
Update - I am not good enough at javascript to modify the code page, but I suspect my idea would work. But, i would need a parent table to get the max record id and pass it back through, which i can do but is a bit annoying...not sure there are any other solutions though.
------------------------------
Mike Tamoush
------------------------------- ChayceDuncan10 months agoQrew Captain
The Max Record ID# would probably only work if the child creation is sequential no? Can you guarantee that the new grandchild is sequenced correctly? From your description the easiest and best solution is still javascript where by instead of having your current button create the record - you move it to a code page, add the record, get the response back and then redirect the user. The best I can offer is some generic functions though that would get you moving:
const tempToken = (dbid) => {return new Promise((resolve,reject) => {var headers = {'QB-Realm-Hostname': 'your realm name','QB-App-Token': 'your app token,'Content-Type': 'application/json'}fetch(`https://api.quickbase.com/v1/auth/temporary/${dbid}`,{method: 'GET',headers: headers,credentials: 'include'}).then(res => {if (res.ok) {return res.json().then(res => resolve(res.temporaryAuthorization));}return res.json().then(resBody => reject({status: res.status, ...resBody}));}).catch(err => reject(err))})}const upsert = (token) => {return new Promise((resolve,reject) => {var headers = {'QB-Realm-Hostname': 'your realm name','Authorization': `QB-TEMP-TOKEN ${token}`,'Content-Type': 'application/json'}var body = {to: 'target dbiddata: [{"field": { value: ""},"field": { value: ""},"field": { value: ""},}],mergeFieldId: commit.mergeFieldId,fieldsToReturn: [3]}fetch('https://api.quickbase.com/v1/records',{method: 'POST',headers: headers,body: JSON.stringify(body)}).then(res => {if (res.ok) {return res.json().then(res => resolve(res));}return res.json().then(resBody => reject({status: res.status, ...resBody}));}).catch(err => reject(err))})}//invoke functionstempToken("").then((token) => {upsert(token).then((res) => {var newRid = res.metadata.createdRecordIds[0]window.location.replace("/dbid/?a=dr&rid=" + newRid)})})
------------------------------
Chayce Duncan
------------------------------