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.
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.
@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
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,
@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.
User | Count |
---|---|
140 | |
132 | |
79 | |
74 | |
74 |
User | Count |
---|---|
209 | |
196 | |
70 | |
62 | |
55 |