cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ThomasVDS
Level: Powered On

Value ComboBox in editable table changes unintentionally to value of first item

Hi,

 

I created an editable table TrainingCatalogue based on the following article: https://powerapps.microsoft.com/en-us/blog/editable-tables/.

But now I have some issue with one of the columns (TrainingProvider) which is a combobox and refering to another table (TrainingProviders).

Without changing anything the value of different records is changed to the one of the first record.

Can someone tell me what I did wrong?

Kr

 

Properties of the ComboBox:

Items: ShowColumns('[dbo].[TrainingProviders]',"ProviderName","ProviderID")

DefaultSelectedItems: Filter('[dbo].[TrainingProviders]',ProviderID=ThisItem.Provider)

SelectMultiple: False

OnChange: Patch('[dbo].[TrainingCatalog]', ThisItem,{ Provider: cmbTrainingProvider.Selected.ProviderID })

I also tried based on https://powerusers.microsoft.com/t5/General-Discussion/Editable-Table-with-ComboBox-and-AutoSave-fun...

Patch('[dbo].[TrainingCatalog]', LookUp('[dbo].[TrainingProviders]',ProviderID=ThisItem.Provider),{ Provider: cmbTrainingProvider.Selected.ProviderID }) -> error -> invalid argument type (Number).Expecting a Record value instead.

You can find some printscreens attached.

TrainingCat_Grid_before.PNGTrainingCat_Grid_after.PNG

5 REPLIES 5
shailendra74
Level 10

Re: Value ComboBox in editable table changes unintentionally to value of first item

Hi @ThomasVDS 

 

It looks like Provider is a lookup field. If so, you need to update provider as:

 

 

{ Provider: {
'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: cmbTrainingProvider.Selected.ProviderID,
Value: cmbTrainingProvider.Selected.TEXT // THE FIELD VALUE TO UDPATE
} 
}

 

Also one more point, try using the ID (sharepoint ID) while updating record

 

Thanks.

 

ThomasVDS
Level: Powered On

Re: Value ComboBox in editable table changes unintentionally to value of first item

@shailendra74Thank you for your reply.

FYI, I am using SQL azure db as datasource.

TrainingID is the primary key of the TrainingCatalog table.

Do I need to add the TrainingID into the Patch formula?

In the TrainingProvider column I show the ProviderName, but I also have the ProviderID which is the foreign key from the TrainingCatalog table.

 

Kr 

shailendra74
Level 10

Re: Value ComboBox in editable table changes unintentionally to value of first item

Hi @ThomasVDS 

 

Use TrainingID as it is key column in patch formula.

 

Thanks.

Highlighted
Community Support Team
Community Support Team

Re: Value ComboBox in editable table changes unintentionally to value of first item

Hi @ThomasVDS ,

Could you plase share a bit more about the "Provider" field in your [dbo].[TrainingCatalog]' table? Does it reference values from the ProviderID TrainingCatalog table?

 

Based on the formula you provided, I think there is something wrong with it. I have made a test on my side, please take a try with the following workaround:

Set the Items property of the TrainingProvider ComboBox (cmbTrainingProvider) to following:

ShowColumns('[dbo].[TrainingProviders]',"ProviderName","ProviderID")

Set the DefaultSelectedItems property of the ComboBox to following:

{
   ProviderName: LookUp('[dbo].[TrainingProviders]', ProviderID = ThisItem.Provider).ProviderName
}

Or

LookUp('[dbo].[TrainingProviders]', ProviderID = ThisItem.Provider)

 

Set the OnChange property of the ComboBox to following:

Patch('[dbo].[TrainingCatalog]', ThisItem, { Provider: cmbTrainingProvider.Selected.ProviderID})

or

Patch('[dbo].[TrainingCatalog]', LookUp('[dbo].[TrainingCatalog]', TrainingID = ThisItem.TrainingID), {Provider: cmbTrainingProvider.Selected.ProviderID})

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ThomasVDS
Level: Powered On

Re: Value ComboBox in editable table changes unintentionally to value of first item

@v-xida-msftI tried your suggestions but without luck

The Provider column in the TrainingCatalog table is a foreign key refering to the ProviderID in the TrainingProvider table (I am using SQL azure)

 

It seems that the issue is not caused by the Patch function in the on select property.

When I consult the screen with the grid and start scrolling down (even in disabled mode) theProvider column starts on updating and changing incorrectly the values. So could the issue be in the defaultSelectedItems property?

I also noticed that the records not always change to the one of the first record. I don't see the logic behind it.

It is strange to see.

 

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,155)