Skip to main content

Notifications

Community site session details

Community site session details

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

Need a help with Multiselect PCf Control

(0) ShareShare
ReportReport
Posted on by 4

Hi All, I'm exploring the below multiselect control and I need to trigger a notifyOutputChanged()

methods on onchange of the text field which stored the id's of the control. 

The PCF control is as below
https://github.com/markcunninghamuk/PCF_Library/tree/main/controls/pcfcontroldemo/MultiSelectControl

 

The field on the form as below. (Same field with one with Control (Red) enabled and Another one with not control enabled (Blue)

Suganthar_1-1694342371658.png

 

The challenge I face here is , when I update the control enabled one, it updates the text field which holds the guid's of the control selected values. but not other way around. 

Upon debugging, I found out the Notifyoutputchanged() changes is not invoking onchange of the text field. 
I have already inspect the property of the directorate text field and got the property information and build the method as below

// Get a reference to the "otherField" element
		const directorateTextField = document.querySelector('[data-id="svdp_directorate.fieldControl-text-box-text"]') as HTMLInputElement | null;
 
		// Add an event listener to "directorateTextField" to trigger notifyChange when it changes
		if (directorateTextField !== null) {
			directorateTextField.addEventListener('change', () => {
				const newValue = directorateTextField.value; // Get the new value of "otherField"
				this.notifyChange(newValue); // Call notifyChange with the new value
			});
		} else {
			console.error('Element not found.'); // Handle the case where the element is not found
		}

 
Please assist me. Let me know if there is any way to refresh the values in the control field when I update the textfield which holds the guids. 

See the error sample below ( I removed the last guid from the comma separated text), it did not update the control below

Before

Suganthar_2-1694342956290.png


After

Suganthar_3-1694343165664.png

 cc @DianaBirkelbach  if you can answer please

 

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Need a help with Multiselect PCf Control

    Hi @Suganthar , 

    In the answer before, I thought you could see that the value is passed in updateView.

    The updateView could be called a few times after that... maybe the right value is passed only the last time the updateView is called

  • Suganthar Profile Picture
    4 on at
    Re: Need a help with Multiselect PCf Control

    Hi @DianaBirkelbach Thanks for the workaround. I tried but no luck, the control did not render. See the screenshot below.

    Suganthar_0-1694518612305.png

     

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Need a help with Multiselect PCf Control

    Hi @Suganthar , 

    Ok, so the updateView gets triggered, but React doesn't render. So we have an issue with this PCF, not a platform issue.

    I saw that in updateView the this.props.value, this.props.topCount (and so on) get changed, but the complete this.props are passed.
    In terms of React, they check if the parameters get changed. Since you don't change the this.props object (only the subproperties), I guess that the pointer of this.props is not changed (so React doesn't rerender).

     

    As a workarround , you could create a new instance of the passed props (using the spread operator). So your renderElement would look like this (use {...this.props} instead of this.props)

    private renderElement() {
    		if (this.props.initialValues != undefined) {
    			this.props.isControlDisabled = this._context.mode.isControlDisabled;
    			this.props.isControlVisible = this._context.mode.isVisible;
    
    			ReactDOM.render(
    				React.createElement(MultiSelectControl, {...this.props})
    				, this._container
    			);
    			console.log("viewUpdated");
    		}
    
    	}

    Let's see if we get further now....

  • Suganthar Profile Picture
    4 on at
    Re: Need a help with Multiselect PCf Control

    @DianaBirkelbach I have debugged the code and I had looked the Render method and its params . it looks like the value is passing correctly, the control is not getting updated

    Suganthar_0-1694436572897.png

    I could not figure it out why the React component is not updating

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Need a help with Multiselect PCf Control

    Hi @Suganthar , 

     

    Accessing the DOM and the onChange events there, are lot safe to rely on.

     

    To debug your issue, please place a console.log in the updateView method (not inside if conditions).

    There you could log the value of your property.

    There could be a few calls to updateView... and maybe only the last call will have the changed value.
    I expect that you'll see the changed value in updateView. If that's the case, the next step would be to check why the React component doesn't get updated when the updateView changes. 

     

    Hope this helps!

     

  • a33ik Profile Picture
    3,304 Most Valuable Professional on at
    Re: Need a help with Multiselect PCf Control

    Hello,

    I would recommend reaching out to an author of the control and asking for advice.

    On a side note - I have a feeling that you are trying to reinvent the wheel. There is a control that has quite similar functionality. Check those articles:

    https://www.ariclevin.com/development/post/multiselect-lookup-pcf-overview/

    https://www.ariclevin.com/development/post/multiselect-lookup-pcf-overview-update-nn/

     

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 69 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 51 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard