Forum Discussion
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
------------------------------
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:
------------------------------
Chayce Duncan
------------------------------
- MikeTamoush5 months agoQrew Commander
Thanks Chase. I think the Max Record ID would work because, lets say this is the scenario:
I am on a record in Table A (Table A has many Table B). I want to push a button while on Table A, have it create a record in table B, delay for a second, then land on that newly created record in Table B.
If the user is on Table A, and the current max record ID in table B is 100, when they push the button it will have to be 101. It doesn't matter what the max child is, I want the max record ID in that entire table (which I can get using a psuedo parent table etc). So I can redirect to that max record ID. Maybe you can help though.
I am using an existing code page. See below for how it returned normally, and how I am trying to get it to return. Can you spot my issue?
My rich text button includes this:
var text RID = ToText([Maximum Record ID#]+1);
var text Pause =
URLRoot() & "db/" & "bpu98ejpu" & "?a=dbpage&pageid=61"
& "&returndbid=bry7tkmnx"
& "&rid=" & $RID ;My code page snip:
const rid = urlParams.get('rid'); //I added these 3 constants. Not in original code
const returndbid = urlParams.get('returndbid');
const rl = prevUrlParams.get('rl');}
function errRdr(){
// Redirects to the previous page, if this page was the previous page as well, then redirect to the app home page
if(document.referrer && document.referrer !== window.location.href) {
// window.location.href = document.referrer; //this was working code
window.location.href = "https://" + window.location.hostname + "/db/" + returndbid + "?a=dr&rid=" + rid + "&rl=" + rl; //i changed to this
}else{// window.location.href = window.location.origin + window.location.pathname; //this was working code
window.location.href = "https://" + window.location.hostname + "/db/" + returndbid + "?a=dr&rid=" + rid + "&rl=" + rl; //i changed to this
}
}
------------------------------
Mike Tamoush
------------------------------- ChayceDuncan5 months agoQrew Captain
Ah - I see what you mean on the max rid. In that case in theory it could work.
In regards to the code - I copied the snippet but it seems to be incomplete / has syntax issues. Can you elaborate on what the main issue is or provide more code?
------------------------------
Chayce Duncan
------------------------------- MikeTamoush5 months agoQrew Commander
This is the code page I am trying to modify.
https://resources.quickbase.com/db/bq8meiyhh?a=dr&key=2
This code page currently pauses for a certain amount of seconds, then returns from where you came. I am trying to modify the return section of the code page to return to a specifc Dbid (my child table dbid) and a specific record (max ID + 1 of child table).
Ill need to pass the max ID +1 into the code page during the button push. And if possible, the Dbid too (even though the dbid could be hard coded into the code page, I prefer passing a variable so the code page is more versatile).
------------------------------
Mike Tamoush
------------------------------