<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem calling functions on Report object in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/200723#M6407</link>
    <description>&lt;P&gt;Hi, I'm able to display my report on my web application, but after that I can't do anything with the Report object returned by powerbi.embed(...). What happens is that anytime I call a function on the object (setFilters, for example), the Promise never enters the "then" nor "catch" part of my code. It's as if the Promise remained pending forever.&lt;BR /&gt;&lt;BR /&gt;On firefox I get these errors for each function I try to call, which I assume are relevant:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://ip1.i.lithium.com/c5c5b86d9a307ec6c5a6906b71384a3378a33a53/687474703a2f2f692e696d6775722e636f6d2f4758314332326e2e706e67" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the relevant sections of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;script src="js/powerbi-client/dist/powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
    var models = window['powerbi-client'].models;
    var permissions = models.Permissions.Read;

    const filter = {
        $schema: "http://powerbi.com/product/schema#basic",
        target: {
            table: "Driver",
            column: "DriverID"
        },
        operator: "In",
        values: [&amp;lt;%= driver_id %&amp;gt;]
    };

    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: '&amp;lt;%= token %&amp;gt;',
        embedUrl: embed_url,
        id: config_id,
        permissions: permissions,
        filters: [filter],
        settings: {
            filterPaneEnabled: false,
            navContentPaneEnabled: false
        }
    };

    var embedContainer = document.getElementById('embedContainer');
    var report = powerbi.embed(embedContainer, config);

    report.on("loaded", function (e) {
        alert('this is successfully called')
    })

    report.setFilters([filter]).then(function (result) {
        alert("never called 1");
    }).catch(function (errors) {
        alert("never called 2");
    });

    report.getPages().then(function (pages) {
        alert('never called 3')
    }).catch(function (errors) {
        alert('never called 4')
    });

&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Sat, 24 Jun 2017 23:04:01 GMT</pubDate>
    <dc:creator>powerbi_noob</dc:creator>
    <dc:date>2017-06-24T23:04:01Z</dc:date>
    <item>
      <title>Problem calling functions on Report object</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/200723#M6407</link>
      <description>&lt;P&gt;Hi, I'm able to display my report on my web application, but after that I can't do anything with the Report object returned by powerbi.embed(...). What happens is that anytime I call a function on the object (setFilters, for example), the Promise never enters the "then" nor "catch" part of my code. It's as if the Promise remained pending forever.&lt;BR /&gt;&lt;BR /&gt;On firefox I get these errors for each function I try to call, which I assume are relevant:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://ip1.i.lithium.com/c5c5b86d9a307ec6c5a6906b71384a3378a33a53/687474703a2f2f692e696d6775722e636f6d2f4758314332326e2e706e67" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the relevant sections of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;script src="js/powerbi-client/dist/powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
    var models = window['powerbi-client'].models;
    var permissions = models.Permissions.Read;

    const filter = {
        $schema: "http://powerbi.com/product/schema#basic",
        target: {
            table: "Driver",
            column: "DriverID"
        },
        operator: "In",
        values: [&amp;lt;%= driver_id %&amp;gt;]
    };

    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: '&amp;lt;%= token %&amp;gt;',
        embedUrl: embed_url,
        id: config_id,
        permissions: permissions,
        filters: [filter],
        settings: {
            filterPaneEnabled: false,
            navContentPaneEnabled: false
        }
    };

    var embedContainer = document.getElementById('embedContainer');
    var report = powerbi.embed(embedContainer, config);

    report.on("loaded", function (e) {
        alert('this is successfully called')
    })

    report.setFilters([filter]).then(function (result) {
        alert("never called 1");
    }).catch(function (errors) {
        alert("never called 2");
    });

    report.getPages().then(function (pages) {
        alert('never called 3')
    }).catch(function (errors) {
        alert('never called 4')
    });

&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jun 2017 23:04:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/200723#M6407</guid>
      <dc:creator>powerbi_noob</dc:creator>
      <dc:date>2017-06-24T23:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem calling functions on Report object</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/202077#M6450</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/34042"&gt;@powerbi_noob&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You shall bind those functions in the "loaded" event, try below sample which works in my test. My understanding is that, before "loaded", the report object is not valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; report.on('loaded', event =&amp;gt; {
 
  report.setFilters([Filter2]).then(function (result) {
        alert("never called 1");
    }).catch(function (errors) {
        alert("never called 2");
    });

    report.getPages().then(function (pages) {
        alert('never called 3')
    }).catch(function (errors) {
        alert('never called 4')
    });
 
 
});
&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Jun 2017 10:06:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/202077#M6450</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-06-27T10:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem calling functions on Report object</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/371368#M11075</link>
      <description>&lt;P&gt;When calling within report.on ('loaded'), i see that report.getPages() function is not available.&amp;nbsp;&lt;/P&gt;&lt;P&gt;while it is available when calling from outside and observerd that promise is always pending.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var report = powerbi.load(embedContainer, config);&lt;/P&gt;&lt;P&gt;report.on('loaded', () =&amp;gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; report.getPages().then(function (pages) {&lt;BR /&gt;&amp;nbsp; // Retrieve first page.&lt;BR /&gt;&amp;nbsp; var firstPage = pages[0];&lt;BR /&gt;&amp;nbsp; firstPage.getVisuals().then(function (visuals) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; console.log(visuals);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;});&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 09:40:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-calling-functions-on-Report-object/m-p/371368#M11075</guid>
      <dc:creator>ne</dc:creator>
      <dc:date>2018-03-07T09:40:01Z</dc:date>
    </item>
  </channel>
</rss>

