web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / My first PCF not working
Power Apps
Answered

My first PCF not working

(0) ShareShare
ReportReport
Posted on by 945

Hi,

 

I'm beginner and looking for some advice for what's wrong with my first PCF. I get the tutorial from Youtube : https://www.youtube.com/watch?app=desktop&v=H7vMXphR8Eo

 

It looks for me the PCF only for show some text in browser, but it seems not working for me. The steps I took :

1.  Go to index.ts in Visual Studio Code then add these variables :

 //Value of the field is stored and use inside the control
	private _value: string;

	//Reference to ComponentFramework Context object
	private _context: ComponentFramework.Context<IInputs>;

	//Reference to the control container HTMLDivElement
	//This element contains all elements of our custom control example
	private _container: HTMLDivElement;

 

2. Add the init method like below:

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement): void
	{
		// Add control initialization code
		this._context = context;
		this._container = document.createElement("div");
		this._value = context.parameters.sampleProperty.raw!;
		this._container.innerText = this._value;
		container.appendChild(this._container)
	}

 

3. Then UpdateView method :

public updateView(context: ComponentFramework.Context<IInputs>): void
	{
		// Add code to update control view
		this._value = context.parameters.sampleProperty.raw!;
		this._context = context;
		this._container.innerText = this._value;
	}

 

While no error on the code, but in my browser, whatever I input text in the Input, nothing change. But the width and height of the box reflected as my setting :

Axal_0-1625382145927.png

 

Is there something I missed ? What could be the problem ?

 

Please help,

Thanks.

I have the same question (0)
  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Axal , 

     

    It looks ok to me. Maybe it could help to restart the Harness (npm start watch). 
    You could try to debug, using the developer tools (F12), and see what happens when the updateView is called.

    The next step could be to upload the PCF im your environment and check if it shows the value there.

     

    Just in case you didn't noticed: the docs were updated. You can find there:

    - tutorials: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/implementing-controls-using-typescript?WT.mc_id=BA-MVP-5004107

     - How-To guides, one of them about how to debug: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/debugging-custom-controls?WT.mc_id=BA-MVP-5004107

     

    Hope this helps!

     

    Kind regards,

    Diana

  • Axal Profile Picture
    945 on at

    Hi @DianaBirkelbach 

    Thank you. Works after npm start watch.

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 405 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 280 Super User 2025 Season 2

#3
Kalathiya Profile Picture

Kalathiya 272

Last 30 days Overall leaderboard