Discussions

Expand all | Collapse all

Passing field into Code Page -

  • 1.  Passing field into Code Page -

    Posted 01-24-2019 20:34
    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");
        }); 
     
      }
    })();



  • 2.  RE: Passing field into Code Page -

    Posted 01-24-2019 21:23
    I got this working


  • 3.  RE: Passing field into Code Page -

    Top
    Contributor
    Posted 01-25-2019 16:33
    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.


  • 4.  RE: Passing field into Code Page -

    Posted 01-25-2019 16:52
    Dan, Thank you! for your reply. I got this to work without using the IOL technique. I used your "Embed">https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&r=yr&rl=hzp">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. 


  • 5.  RE: Passing field into Code Page -

    Top
    Contributor
    Posted 01-25-2019 17:23
    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.


  • 6.  RE: Passing field into Code Page -

    Posted 01-25-2019 17:35
    Dan,

    I created a URL formula field --- inserted the embedded URL from PowerBI below --- and inserted my "filter field" - [state] -- I may have broken many coding rules -- but it works...

    URL Formula
    "http..app.powerbi.com/reportEmbed?reportId=802c359548-aaa8-b910f9725ea0&groupId=178e0-41741f6a5853&autoAuth=true&pageName=ReportSection&$filter=Accounts%2FCategory%20eq%20%27"&URLEncode([State])&"%27" 


  • 7.  RE: Passing field into Code Page -

    Top
    Contributor
    Posted 01-25-2019 17:43
    Yes I go that but PowerBI in their docs makes reference to using both filter= and $filter=

    ?filter=Store/Territory eq 'NC'

    https://docs.microsoft.com/en-us/power-bi/service-url-filters

    Does it take both or is one of these a typo?

    This seems like a viable way to bring PowerBI into QuickBase so I myself want to understand their API better.


  • 8.  RE: Passing field into Code Page -

    Posted 01-25-2019 18:03
    Dan,

    The difference may be with the embedding method -- the method I'm using -- is a new method called "Secure Embed" vs Publish to web method. I'm not sure why the difference -- but i just replaced the $ with a ? and it did not work ---

    Secure Embed and the nonsecure (publish to web) methods are both apart of the Power BI service -- the Secure Embed functionality requires a Pro license ($10/month) -- Publish to web does not require Pro -- you can use the Free version. The secure embed option has to be generated on the Power BI service vs Power BI desktop -- there is also the developer embedding --- requires enterprise license -- the Pro version is a great option for small business...and low coders like myself...

    Secure Embed  (blog article)

    Secure Embed (help docs)


  • 9.  RE: Passing field into Code Page -

    Posted 01-25-2019 18:27
    Dan,

    ? - is used if you want to filter a report --- (share a filtered link) -- takes you to a report on the Power BI service.

    $ - is used for Secure Embedding -- 

    Both are hosted on the Power BI service -- ($ - for embedding)  & (?-non embedded)


  • 10.  RE: Passing field into Code Page -

    Posted 08-09-2019 10:47
    Can you tell me how you got this working? I am trying to get a date field into a code page and just cant get it there no matter what I do. I tried the IOL option but my page is HTML so for some reason it wont work


  • 11.  RE: Passing field into Code Page -

    Posted 08-09-2019 10:47
    Can you tell me how you got this working? I am trying to get a date field into a code page and just cant get it there no matter what I do. I tried the IOL option but my page is HTML so for some reason it wont work


  • 12.  RE: Passing field into Code Page -

    Posted 08-09-2019 14:09
    No need for a code page  -- if you are trying to embed power bi into a record form

    Embedding TIP:

    I used the steps below to embed a Power BI report within a Quickbase form/record and passed a Quickbase field into the power bi embedding URL for the purpose of filtering the Power BI report.

    1st) I created a URL formula field --- inserted the embedded URL (Secure Embed method) from PowerBI below --- and inserted my qbase "filter field" - [state] -- I may have broken many coding rules -- but it works...

    [URLFormulafield]
    "http..app.powerbi.com/reportEmbed?reportId=802c359548-aaa8-b910f9725ea0&groupId=178e0-41741f6a5853&autoAuth=true&pageName=ReportSection&$filter=Accounts%2FCategory%20eq%20%27"&URLEncode([State])&"%27"    


    2nd) Then created a formula Rich text field with the following formula: (see Dan's Pastie)

    "<img data-url='" & [URLformulafield] & "'" &
    " src onerror='

    (async () => {
      var url = this.dataset.url;
      this.outerHTML = '<iframe src=${url} width=700px height=600px></iframe>';
    })();

    '>"
    No need for a code page


  • 13.  RE: Passing field into Code Page -

    Posted 08-09-2019 14:48
    Ty, actually already got it. Went a different route as well for anyone out there trying to do this. If you do something like var date = location.hash; put date where you need the field on your code page, and then in your URL at the end do #[field name] you will get the same result. As everyone else has said, probably not the best way but works till i figure something else out