Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Load HTML from file inside PCF Component

(0) ShareShare
ReportReport
Posted on by 26

So, I've seen these PCF samples where random HTML elements are being created and populated via javascript by using

 

 

 

myDiv.innerHtml = "<some html inside a string/>";

 

 

 

Instead of that, what I intend to do is to load the HTML from an actual HTML file declared as a resource in my control's manifest.

 

This is what I've tried:

 

 

 

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
	{
		let appDiv: HTMLDivElement = document.createElement('div');

		context.resources.getResource("ui.html", data =>{
			appDiv.innerHTML = atob(data);
		}, () => {
			alert("failed");
		});

		// Container appends the HTML structure
		container.appendChild(appDiv);
	}

 

 

 

where ui.html contains the following:

 

 

 

<label>this is the actual UI</label>

 

 

 

and is declared in ControlManifest.Input.xml as follows:

 

 

 

<resources>
 <code path="index.ts" order="1"/>
 <html path="ui.html" order="2"/>
</resources>

 

 

 

however, when debugging via "npm run start", I get a null value for "data".

 

What's the correct way to use proper HTML files inside PCF components?

 

  • DGA205 Profile Picture
    8 on at
    Re: Load HTML from file inside PCF Component

    Hi. I think exactly the same.

  • MichaelFP Profile Picture
    1,831 Super User 2025 Season 1 on at
    Re: Load HTML from file inside PCF Component

    Please take a look on what I've done. I'm already using SASS and PCF. you can do it the same with VueJs working with the loaders from webpack.

     

    https://powerusers.microsoft.com/t5/News-Announcements/Using-SASS-on-your-PCF-Project/ba-p/614222

     

     

  • rexkenley Profile Picture
    203 on at
    Re: Load HTML from file inside PCF Component

    @fberasategui 

     

    You can try editing the pcf webpack config file and add the html-loader to handle your html files.

  • JamesMcWhinney Profile Picture
    11 on at
    Re: Load HTML from file inside PCF Component

    I am trying to do the same thing and not having any luck.

    Did you figure it out?

    Thanks!

  • Karishma_Kuria Profile Picture
    2 on at
    Re: Load HTML from file inside PCF Component

    Hi,

     

    Did you get any resolution for implementing PCF using Vue.js. 

  • ScottDurow Profile Picture
    1,039 on at
    Re: Load HTML from file inside PCF Component

    Lots of the Xrm.* is stubbed in the test harness - so you might be in luck!

     

    You are welcome - let me know how you get on!

     

    Cheers,

    Scott

  • Federico Berasategui Profile Picture
    26 on at
    Re: Load HTML from file inside PCF Component

    Hmm.... Looking at the Office UI Fabric, it's kinda compelling. I might get myself a crash course on React but not yet. What I need right now is to be able to "embed" a quick and dirty HTML + VueJS UI into a PCF component. 

     

    I have debugged a little bit and I figured out the getResource() function *might* be stubbed out in the local sandbox environment. I'll go ahead and pack the solution and install it into a CDS instance and come back with feeback on that.

     

    Anyways, you've just opened my mind a little bit, which is a hell of an achievement.

    Thank you!

  • ScottDurow Profile Picture
    1,039 on at
    Re: Load HTML from file inside PCF Component

    With respect to the UI components - I was referring to the dynamic nature of UI components. CSS is just half the story. For instance, dropdowns with autosuggest popups, data grids with resizable columns and virtual scrolling etc. office ui fabric does all this for you - you only need to concentrate on the logic behind your UI. (e.g. https://developer.microsoft.com/en-us/fabric#/controls/web/dropdown)

     

    Your point about separating out logic from the UI is a really good one. I always use the MVVM pattern - combining Mobx with React. That way you make your ViewModels unit testable without the UI concerns.

     

    You seem dead-set against React,  I'm not going to try and change your mind! The great thing about web development is that there are so many libraries and patterns to choose from - or maybe that's the problem here! 🤣 https://dayssincelastjavascriptframework.com/

     

     

     

     

  • Federico Berasategui Profile Picture
    26 on at
    Re: Load HTML from file inside PCF Component

    That's fine. But then again, Microsoft has infinite budget and infinite manpower. I have no one in my team with React knowledge, I have no React knowledge myself, and I have no chances of hiring anyone with React knowledge due to budget limitations. Also, the look and feel of a web UI is determined by CSS, I don't see how my choice of JS framework will affect my ability to make my controls look "native" on CDS.

  • ScottDurow Profile Picture
    1,039 on at
    Re: Load HTML from file inside PCF Component
    Fair enough! Do consider that you might be making things hard for yourself if you want to create extensions that look like the first party apps.

    PowerApps itself is written in React with the office ui fabric.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard