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 8

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 8

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.

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.
Highlighted
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
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 297 members 4,630 guests
Please welcome our newest community members: