Forum Discussion

BradElmore's avatar
BradElmore
Qrew Assistant Captain
6 years ago

Passing field into Code Page -

I'm trying to embed an iframe using IOL-- I'm able to embed the page I want but I'm not able to pass my qbase field (var state = $("catformula", xml).text();)   -- into the url below.....

I'm sure the issue is how I'm coding the "filtering" part of my URL --- &$filter=Accounts/Category eq 'qbasefield' 

Any help is greatly appreciated.....the code I'm using is listed below.


(function(){
  var querystring=document.location.search;

  if(/a=dr/i.test(querystring)) {
    //DISPLAY RECORD PAGE
    $("img[qbu=module]").closest("td").css("background-color","#FFFFFF");

    var apptoken = "dwnxji38j";
    $.ajaxSetup({data: {apptoken: apptoken}});
    var dbidAccounts = "bjec5";

    var promise = $.get(dbidAccounts, {
      act: "API_DoQuery",
      query: "{3.EX." + kRid + "}",
      clist: "21"
    });
    $.when(promise).then(function(xml) {
      var state = $("catformula", xml).text();

      var url = "";
      url += "https://app.powerbi.com/reportEmbed?reportId=802c3595-add7-4a48-aa725ea0&groupId=178e260d-ca8b-4...;
      url += "&$filter=\"Accounts%2FCategory\"eq'" + state + "'";   

      $("<iframe></iframe>")
        .attr("frameborder", "0")
        .attr("width", "100%")
        .attr("height", "450")
        .attr("src", url)
        .insertAfter("#sect_s14");
    }); 
 
  }
})();

    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      FWIW, I had a quick look at the PowerBI docs last night. One small thing I was confused by is their docs have examples where the filter parameter is specified both with and without the dollar sign so I was wondering which version you got to work:
      url += "&$filter=\"Accounts%2FCategory\"eq'" + state + "'";   
      Also, with regard to your own code you might benefit from using backtick quotes when specifying your filter parameter:
      var state = $("catformula", xml).text();
      ...
      url += '&$filter="Accounts/Category" eq '${state}'';

      Backtick quotes allow you to do "string interpolation" where any expression with ${} is evaluated and substituted into the string.

      Quite frankly QuickBase should adopt backtick quotes in their own formula language (or replace it with JavaScript) so you can avoid concatenating dozens of string fragments together.
    • BradElmore's avatar
      BradElmore
      Qrew Assistant Captain
      Dan, Thank you! for your reply. I got this to work without using the IOL technique. I used your "Embed a web Page"...using Inline script within a rich text formula field. This option works great!!! I created a URL formula field to build my embed url and to pass needed filters. Not sure if there are options to remove the frameboarder within an inline script iframe or if additional options are available to control the iframe. Using your Inline scripts techniques in this case --- make this task much easier to manage and got me thinking -- how else can inline scripts be leveraged (ex: control the size of the qbase charts embedded within a qbase form). Thank you for all you do to advance qbase. 
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      Yes the benefit from using the "inline script" or 3Q&S Technique is that (1) it is self contained and requires no other setup other the the Rich Text Formula field and (2) you don't have to make reference to a section id as the formula field itself can be used as the target:

      .insertAfter("#sect_s14");

      But what did you do with the $filter parameter? PowerBI has docs both with and without the dollar sign.

      > how else can inline scripts be leveraged

      Once you get JavaScript loaded - and to some extent it does not matter how you do it - you can do just about anything.