cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blumi78 Regular Visitor
Regular Visitor

Custom Visual: Using Javascript Promises in Internet Explorer 11

IE 11 still doesn't support ES2015 features like Promises.

 

My default approach here is to use a Polyfill lib, include it in "externalJS" section of pbiviz.json and add "es2015" as lib to tsconfig.json.

 

As a result, the custom visual compiles, but the first use of a Promise results in an error:

new Promise((resolve, reject) => {
    resolve();
});

ERROR TypeError: Erlaubnis verweigert.
Die Eigenschaft "getOwnPropertyNames" eines undefinierten oder Nullverweises kann nicht abgerufen werden.
In english it's probably

ERROR TypeError: Permission denied.
The "getOwnPropertyNames" property of an undefined or null reference can not be retrieved.

 

However, when I write instead

new window["Promise"]((resolve, reject) => {
    resolve();
});

.. it works as expected.

 

What's happening here?

10 REPLIES 10
Moderator v-viig
Moderator

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

This issue is related to the fact that Power BI creates a copy of window object to isolate PBI code from Custom Visual's code.

Such solution might produce issues with some native methods and it produces issues with importing external libraries.

 

Meanttime, we're implementing Webpack based PBIVIZ tools to support ES2015 and get rid of this issue by additional code isolation. You can already check it out. It's avaialbe under beta tag on NPM.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

blumi78 Regular Visitor
Regular Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

Tried the beta version (@2.0.1) of the powerbi-visuals-tools package. Gives me a "Syntax error" in IE11 right away with the sample visual that you get with "pbiviz new". Other browsers work, though.

 

If you say, it's safe to use window["Promise"], then I can work with that.

Moderator v-viig
Moderator

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

Yeah, window["Promise"] will probably work well.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

tpatel Frequent Visitor
Frequent Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

Can you please show me the function how to implement?

Highlighted
blumi78 Regular Visitor
Regular Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

Replace all "Promise" - calls with "window['Promise']"

 

What exactly do you want to know?

tpatel Frequent Visitor
Frequent Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

U mean in PowerBi.js replace Promise calls?

blumi78 Regular Visitor
Regular Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

In your Custom Visual code, usually all *.ts files.

Moderator v-viig
Moderator

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

Have you resolved the issues?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

 

 

tpatel Frequent Visitor
Frequent Visitor

Re: Custom Visual: Using Javascript Promises in Internet Explorer 11

not yet. Below is the function that I have.

 

 

function Print() {
var embedContainer = $('#reportContainer')[0];

// Get a reference to the embedded report.
report = powerbi.get(embedContainer);

// Trigger the print dialog for your browser.
report.print()
.catch(function (errors) {
Console.log(errors);
});
}

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors