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 / Need a help with Multi...
Power Apps
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

 

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    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/

     

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    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!

     

  • Suganthar Profile Picture
    4 on at

    @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

    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

    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

    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

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard