Discussions

Expand all | Collapse all

Is there any API for getting App Token & DBIDS w.r.t to table name?

Rohit Agarwal09-04-2017 17:39

  • 1.  Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-04-2017 17:39


  • 2.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-05-2017 12:44
    Application Tokens are associated with Applications not individual tables. Additionally, there can be several Application Tokens associated with an Application. Given these two observations it isn't clear what your original question is asking or what you are trying to accomplish.

    In any case when you are trying to automate some task across your entire account it can be problematic using the API because there is often no common Application Token to use within your script (unless you manually set this up). In these cases you can still write the script but you have to use non-API methods. This may seem unusual if it is your first exposure to the technique but you can GET or POST to any QuickBase endopoint URL using AJAX methods.


  • 3.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-05-2017 17:19
    You didn't get my question. 
    API that gives me DBID w.r.t to table name means I pass table name as the parameter and I get the DBID.


  • 4.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-05-2017 17:21
    So where does the part about "App Token" fit into your reformulated question?


  • 5.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-05-2017 17:31
    > I pass table name as the parameter and I get the DBID.

    Like this:

    var name = "250 Bottles of Beer on the Form";

    $.get("main?act=API_GrantedDBs")
      .then(function(xml) {
        var dbid = $("dbname", xml).filter(function() {
          return $(this).text() === name;
        }).next("dbid").text();
        console.log(dbid);
      })

    //output
    bj4vxvurn


  • 6.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-06-2017 20:08
    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


  • 7.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 15:05
    Thank 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.


  • 8.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-07-2017 15:09
    Just dip into one of QuickBase global variables:

    gReqAppDBID


  • 9.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 17:37
    Where I will find this gReqAppDBID Global Variable.


  • 10.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-07-2017 17:40
    It 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.


  • 11.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 17:44
    Thank you so much.


  • 12.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 18:09
    can I use gReqAppDBID in Formula URL field type?


  • 13.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-07-2017 18:19
    No. You can only use it within JavaScript.


  • 14.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 18:28
    I 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?


  • 15.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Top
    Contributor
    Posted 09-07-2017 18:31
    I 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.


  • 16.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 18:34
    Alright, 
    Any solution you will suggest in order to access Quickbase Globals in the code page.


  • 17.  RE: Is there any API for getting App Token & DBIDS w.r.t to table name?

    Posted 09-07-2017 18:48
    I used 

    "javascript:$.getScript('h">https://emc-brs.quickbase.com/db/">https://xxx.com/db/' + gReqAppDBID + '?act=dbpage&pagename=xxx.js');"

    in formula field than in my xxx.js 
    I did window.location.href = 'xx.html'


    But it's not working.