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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / COMBO BOX OnChange upd...
Power Apps
Answered

COMBO BOX OnChange update with incorrect row value to collection

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

My app is a Power App canvas. I develop a combo box in a gallery. The Combo box data source is an API endpoint. I implement an Update formula in combo box OnChange. The Update formula should update the item data of the collection with the selected data id. When run the application, the first row is updated successfully. However, when second row added and combo box updated, the collection item of second row updated with the value of the first row. And the third and so on rows have the same issue.

The update formula is implemented as below, the issue is serviceTreeId is always set with first row combo box selected id. The expected behavior should be serviceTreeId is set with value of the combo box that user updated.

JeffHe_0-1653281035572.png

 

BTW, when I move the Update formula to OnSelect, the data update correctly. However, it has other issue, so it is not a perfect workaround.

Categories:
  • JeffHe Profile Picture
    Microsoft Employee on at

    Update one information: The Combo box data source is an API Endpoint.

  • Verified answer
    v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @JeffHe ,

     

    I have made a test with the Patch() function and it seems that works fine.

     

    1. Here is my data source.

    vyujincuimsft_0-1653470315642.png

    2. Here is the data source for the Combo Box, which is a collection.

    vyujincuimsft_1-1653470570755.png

    3. Select the Combo Box Control and apply the following formula on its OnChange property as:

    Patch(datasource,ThisItem,{serviceTreeId:ComboBox2.Selected.id})

    vyujincuimsft_2-1653470679364.png

    Result:

    patch.gif

    vyujincuimsft_3-1653470931755.png

     

     

    Best Regards,
    Charlie Choi

  • JeffHe Profile Picture
    Microsoft Employee on at

    Hi, @v-yujincui-msft , thank you for your reply. I tried your solution, I think you have not set  "defaultSelectedItems", so I removed the formula of "defaultSelectedItems". Although the collection updated, but the selected value didn't show on the combo box UI. Is there any solution for this?

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @JeffHe ,

     

    Here is the configuration of my Combo Box Control. Hope it helps.

    vyujincuimsft_0-1653532823627.png

     

     

    Best Regards,
    Charlie Choi

  • JeffHe Profile Picture
    Microsoft Employee on at

    Hi, @v-yujincui-msft , thank you for sharing. So when Patch or Update used in OnChange, the selected item value didn't show in the combo box. We need to show the selected item in another component. Do my understand correct?

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @JeffHe ,

     

    Sorry i am a little confused, could you please share a screenshot of the problem you encountered?

    You could change the display text of the Combo Box by editing the Fileds property.

    vyujincuimsft_0-1653535477066.png

     

     

    Best Regards,
    Charlie Choi

  • JeffHe Profile Picture
    Microsoft Employee on at

    Hi @v-yujincui-msft , sorry for confusing. I mean I expect the selected item would be show like below. But actually it didn't show. Can I make it show?

    JeffHe_0-1653536157539.png

     

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @JeffHe ,

     

    Do you want the Combo Box Control to display the corresponding text by default based on the serviceTreeId of this record?

    Maybe you could try to select the Combo Box and apply the formula on its DefaultSelectedItems property like this:

    [LookUp(testcollection,ThisItem.serviceTreeId=id).value]

    vyujincuimsft_0-1653542569579.png

     

     

    Best Regards,

    Charlie Choi

  • JeffHe Profile Picture
    Microsoft Employee on at

    Hi, @v-yujincui-msft thank you! I confirm that when use collection as data source there is no problem. But my implementation uses API Endpoint as data source, so that user can search backend data by keyword. The "Items" and "defaultSelectedItems" are both get from API Endpoint. Is there anything I need take care when I use API Endpoint as data source?

     

    JeffHe_0-1653547486338.png

     

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @JeffHe ,

     

    Sorry, i don't know what the data you got looks like.

    Maybe you could consider saving the data you get from the API Endpoint into a collection and then use it.

    In addition, you could try to replace the collection with the data you get from the API Endpoint in the formula i provided.

    vyujincuimsft_0-1653548168830.png

    or

    vyujincuimsft_1-1653548248446.png

     

     

    Best Regards,

    Charlie Choi

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard