Forum Discussion
_anomDiebolt_
8 years agoQrew Elite
Or this version which employs Async / Await:
(function(){
async function getDBID(name) {
var xml = await Promise.resolve(
$.get("main?act=API_GrantedDBs")
);
var dbid = $("dbname", xml).filter(function() {
return $(this).text() === name;
}).next("dbid").text();
return dbid;
}
var name = "250 Bottles of Beer on the Form";
getDBID(name).then(function(dbid) {
console.log(dbid, name)
});
})();
//output:
//bj4vxvurn 250 Bottles of Beer on the Form
- RohitAgarwal8 years agoQrew CadetThank you so much,
One last question.
Is there any API to get Application ID.
for ex-
I am in Application X. I write some script in order to get Application ID. - _anomDiebolt_8 years agoQrew EliteJust dip into one of QuickBase global variables:
gReqAppDBID - RohitAgarwal8 years agoQrew CadetWhere I will find this gReqAppDBID Global Variable.
- _anomDiebolt_8 years agoQrew EliteIt is a global variable on every QuickBase page. Go to any QuickBase page, open up the console and type gReqAppDBID and it will spit out the dbid.
- RohitAgarwal8 years agoQrew CadetThank you so much.
- RohitAgarwal8 years agoQrew Cadetcan I use gReqAppDBID in Formula URL field type?
- _anomDiebolt_8 years agoQrew EliteNo. You can only use it within JavaScript.
- RohitAgarwal8 years agoQrew CadetI have a formula URL field with formula
- URLRoot() & "db/" & Dbid() & "?a=dbpage&pagename=xxx.html&pid=" &[record-id]
when I land to xxx.html
I won't be able to access gReqAppDBID global variable. Any comments? - _anomDiebolt_8 years agoQrew EliteI assumed you were injecting your code into a QuickBase authored page in which case the global is available. However, code pages are completely empty and consist of only the code you explicitly include - so you don't have access to any QuickBase globals nor any libraries such as jQuery unless you load them yourself into the code page.
- RohitAgarwal8 years agoQrew CadetAlright,
Any solution you will suggest in order to access Quickbase Globals in the code page.