cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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
Highlighted
Anonymous
Not applicable

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.

 

Highlighted
Helper III
Helper III

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

@AnonymousThank 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 

Highlighted
Anonymous
Not applicable

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
Community Support

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
Helper III
Helper III

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
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,396)