query using a variable in html page

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • In Progress
<script>
var a=1594;
console.log(a)
</script>
<script lang="javascript" src="https://tsemerge.quickbase.com/db/
DBID?a=API_GenResultsTable&apptoken=APPTOKEN&jht=1&query={'29'.EX.+'a'}AND{'6'.XEX.''}AND{'7'.EX.''}OR{'7'.AF.'today'}&clist=30.20.14.6.7.8&slist=6&options=sortorder-A">


How would {'29'.EX.+'a'} this statement work? I want a to be kRid eventually.
Photo of Sania

Sania

  • 476 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Chuck Grigsby

Chuck Grigsby

  • 1,978 Points 1k badge 2x thumb
This is how I would do it. note you can wrap URL in a var or just use the DBID if used within the app. 

var query= "{'29'.EX.'" + kRid + "'}AND{'6'.XEX.''}AND{'7'.EX.''}OR{'7'.AF.'today'}";

 $.get(DBID, {
                        act: "API_GenResultsTable",
                        query:query,
                        clist:"30.20.14.6.7.8",
                        slist: "6",
                        options:"sortorder-A"
                    }, function(xml) {

                        $("#results").html(xml)
                    })
Photo of Sania

Sania

  • 476 Points 250 badge 2x thumb
I have this html page in a dialog box.
Photo of Chuck Grigsby

Chuck Grigsby

  • 1,958 Points 1k badge 2x thumb
That should be fine. Just use the script tags like you did if you need to. Just change the #results to whatever element you want the report to display.
Photo of Sania

Sania

  • 476 Points 250 badge 2x thumb
That is not really working for me, there is no way to include a here {'29'.EX.+'a'}?
Photo of Chuck Grigsby

Chuck Grigsby

  • 1,958 Points 1k badge 2x thumb
Feel free to reach out if you want to go through a demo of one my HTML pages. Which is loaded on dashboards but could be loaded anywhere. But you would need to get your values for your variables then change the source. I don't think you can enter a variable in the source URL. 

chuck@chuck.support
Photo of Chuck Grigsby

Chuck Grigsby

  • 1,958 Points 1k badge 2x thumb
also the above probably won't work because I didn't include the apptoken
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,482 Points 20k badge 2x thumb
You are not going to be able to dynamically set the src of a script tag that references ?act=API_GenResultsTable&jht=1. This is because that script file references document.write() and that method operates differently between when it is called on initial page load and when it is called later.

Moreover, nobody uses  document.write() anymore. It is archaic construct left over from the early days of the web and is only used for some obscure edge cases related to having a backup for a missing CDN file. If you are writing your own code page and want to use ?act=API_GenResultsTable call it with &jsa=1 instead and generate your report using a template such as Mustache. Search for API_GenResultsTable and Mustache for historic examples and I think you will find material you can adopt.