Forum Discussion
BlakeEstep
Qrew Trainee
Thanks for the reply.
I added the recID to the URL button and started on the code page function. What do you mean exactly by parse the URL for "recID="? is that something I am doing in my submit function? I copied some other code from a different javascript function we use and I'm trying to adapt it for this. Let me know if i'm close.
------------------------------
Blake E
------------------------------
I added the recID to the URL button and started on the code page function. What do you mean exactly by parse the URL for "recID="? is that something I am doing in my submit function? I copied some other code from a different javascript function we use and I'm trying to adapt it for this. Let me know if i'm close.
function submitData(){ var dbid = "dbid"; var dbidTable = "dbidTable"; var apptoken = "apptoken"; $.ajaxSetup({data: {apptoken: apptoken}}); var promise = $.get(dbidTable, { act: "API_EditRecord", rid: QBU_rid, _fid_8: number, window.close() } $.when(promise).then(function submitData(){ $.get() & location.reload(true); }); }
*note: the dbid, dbidtable, and apptoken have been changed to generic names as to not show the actual apptoken.
------------------------------
Blake E
------------------------------
AustinK
5 years agoQrew Commander
There are a few different ways to parse a url but so as not to reinvent the wheel we can just take someones code and use it for this. If you want to play around with it I would look into window.location.href or others. You could then parse the URL however you wanted, but the below site has it done for you.
This page has a function you can copy and when ran it will give you to value of whatever you search for. So if you did getQueryVariable("recID") on a URL like this "https://yourCompany.quickbase.com/db/tableID?a=er&r=yau&recID=12345" it would return 12345. Then you could store that number and use it in your next call to edit that record.
I'm pretty exhausted today so I may miss something obvious here. Looking at your SubmitData function the only thing that really jumps out is I am not sure you can do window.close inside of there like that. You might look into the "success" or "complete" parameter for jquery ajax. There may be a better way though.
This page has a function you can copy and when ran it will give you to value of whatever you search for. So if you did getQueryVariable("recID") on a URL like this "https://yourCompany.quickbase.com/db/tableID?a=er&r=yau&recID=12345" it would return 12345. Then you could store that number and use it in your next call to edit that record.
I'm pretty exhausted today so I may miss something obvious here. Looking at your SubmitData function the only thing that really jumps out is I am not sure you can do window.close inside of there like that. You might look into the "success" or "complete" parameter for jquery ajax. There may be a better way though.
- BlakeEstep5 years agoQrew TraineeThank you for helping. I finally got this working with your help.
On the URL we added the Record ID field so it could be parsed. Once we had that we could use that to pass the information needed to the child table and related Record ID.
As of right now I just have the formula URL button open up in a new tab and I have a bit of javascript in the code page that will close the window once everything has processed. I know there is a way to return to the edit record page of the parent but was having enough issues with it that I gave up and just pasted the close window code.
You might also notice that I was experimenting with selecting an item from a drop-down and submitting that value to a field. That is fully working as well.
<form align=center> <select id="products" onchange="getProduct()" size="1"> <option>Product 1</option> <option>Product 2</option> <option>Product 3</option> <option>Product 4</option> <option>Product 5</option> <option>Product 6</option> </select> <br/> <br/> <input type="button" onclick="decrementValueTen()" value="-10" /> <input type="button" onclick="decrementValueFive()" value="-5" /> <input type="button" onclick="decrementValueOne()" value="-1" /> <input type="text" size="1" id="number" value="0" readonly /> <input type="button" onclick="incrementValueOne()" value="+1" /> <input type="button" onclick="incrementValueFive()" value="+5" /> <input type="button" onclick="incrementValueTen()" value="+10" /> <br /><br/> <input type="button" onclick="copyNumber()" value="Submit" /> </form> <script> var rollerValue = parseInt(document.getElementById('number').value); var apptoken = "YourTokenGoesHere"; var dbid = "AppIDHere"; var dbidTable = "TableIDHere"; var URLroot = "https://website.quickbase.com/db/"; var productNumber; var productName; function copyNumber(){ var recordID = getQueryVariable("recID"); var URLONE = URLroot + dbidTable + "?act=API_addRecord" + "&_fid_12=" + recordID + "&_fid_6=" + productName + "&_fid_8=" + rollerValue + "&apptoken=" + apptoken; location.href = URLONE; window.open('','_parent',''); window.close(); } function getProduct() { productNumber = document.getElementById("products").selectedIndex; productName = document.getElementById("products").options[productNumber].text; } function getQueryVariable(variable){ var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } function incrementValueOne() { rollerValue++; document.getElementById('number').value = rollerValue; } function incrementValueFive() { rollerValue = rollerValue + 5; document.getElementById('number').value = rollerValue; } function incrementValueTen() { rollerValue = rollerValue + 10; document.getElementById('number').value = rollerValue; } function decrementValueOne() { if (rollerValue > 1) { rollerValue = rollerValue - 1; } else { rollerValue = 0; } document.getElementById('number').value = rollerValue; } function decrementValueFive() { if (rollerValue > 5) { rollerValue = rollerValue - 5; } else { rollerValue = 0; } document.getElementById('number').value = rollerValue; } function decrementValueTen() { if (rollerValue > 10) { rollerValue = rollerValue - 10; } else { rollerValue = 0; } document.getElementById('number').value = rollerValue; } </script>
------------------------------
Blake E
------------------------------
Related Content
- 5 months ago
- 6 months ago
- 3 months ago