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

Community site session details

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

Auto-Complete for Text Field not triggering onChange event

(0) ShareShare
ReportReport
Posted on by 9

I have written some javascript code that should execute when a country field has changed.  I download the CC_AutoComplete_Name control which is supposed to be from Microsoft.  It works fine.  The problem is that when the value is changed, it does not trigger the onChange event.  Also, my code updates the field, but it doesn't show on the form but if I save the form, the new value is saved and displayed on refresh.

 

Is there other options for autocomplete?  This is for a Country field on a contact/account form and we need to make sure that the correct country spelling/format is entered.

 

Thanks

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at
    Re: Auto-Complete for Text Field not triggering onChange event

    Hello,

    I built such a control awhile ago and shipped it with my controls toolkit. You can check it out - https://github.com/AndrewButenko/ABControlsToolkit/wiki/Text-Autocomplete-Control

  • dipetersen Profile Picture
    9 on at
    Re: Auto-Complete for Text Field not triggering onChange event

    Thank you.  I'm limited to controls that I create or ones that Microsoft creates.

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at
    Re: Auto-Complete for Text Field not triggering onChange event

    I'm afraid the other option would be to develop your own Autocomplete PCF control.

  • dipetersen Profile Picture
    9 on at
    Re: Auto-Complete for Text Field not triggering onChange event

    I was able to get it to throw the onChange event.  I had to remove all of my custom code, then remove the control, replublish the solution, then add the control back and add the event.  Now it works. 

     

    I have one other problem with the control. If I update the control using 


     

    context.getAttribute('address1_country').setValue(newCountry);​

     

     

    This will update the value of the field and will save the new value when Save is pressed.  It doesn't update the screen so the field still displays the old value.  If I do a form refresh, the new value is displayed.  I don't want to have to do a full form refresh each time the value is changed.  Is there another way to force that field to display the new value without refreshing the whole form?

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at
    Re: Auto-Complete for Text Field not triggering onChange event

    @dipetersen did you create your own control for that purpose? If that's the case seems that your code doesn't handle updateView of the control when the update of the field value comes in. Can you please provide the code of your PCF control?

  • dipetersen Profile Picture
    9 on at
    Re: Auto-Complete for Text Field not triggering onChange event

    @a33ik This is a Microsoft control.  The control name is CC_AutoComplete_Name and it came pre-installed in our CRM tenant.  Is there a way using the executionContext or formContext to redraw a control after programmatically setting a value?

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at
    Re: Auto-Complete for Text Field not triggering onChange event

    Gotcha. The only thing I can think of is refresh - https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data/refresh

  • dipetersen Profile Picture
    9 on at
    Re: Auto-Complete for Text Field not triggering onChange event

    I did the data refresh

    context.data.refresh(false).then(
     (ret) => {
     console.log('data refresh success', ret);
     },
     (ret) => {
     console.log('data refresh error: ', ret);
     }
     );

     

    When I click 'Save' on the form, my code sets the Country value and then I did the data.refresh.  I can see that the code executed, but nothing changed on the screen so I don't think a data.refresh works for what I need.

     

    I tried the refresh with both True and False and I didn't see any difference.  

     

    Back to docs!  There has to be a way! 

     

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at
    Re: Auto-Complete for Text Field not triggering onChange event

    I believe that OOB control is glitchy. I would highly recommend developing your own control.

    Here is what you might try but it's ugly because it will refresh the whole page:

    https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto#pageinput-parameter

    Xrm.Navigation.navigateTo({
    	pageType: "entityrecord",
    	entityName: context.data.entity.getEntityName(),
    	entityId: context.data.entity.getId()
    });

     

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

Coming soon: forum hierarchy changes

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 308 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 222 Super User 2025 Season 2

Last 30 days Overall leaderboard