I have an Audit app made in PowerApps which saves the answers to 18 questions to a database. I have another screen which allows users to edit the answers to those questions. I can display the previous answers and edit them but can't seem to update the original records in the db. It just displays the original records in the db. My code for the 'Save changes' button is below...
Update(AuditCollection,First(Filter(AuditCollection,ID=Value(IDGal_1.Text))),{AuditID:IDAuditVar, Question:txtQuestion.Text, Answer:txtComplianceEdit1.Text,Action :txtActionsEdit1.Text,AddToActionPlan:tglActionPlanEdit.Value});
I've also tried adding Collect('dbo.auditanswers',AuditCollection) on the end but this stores a further set of 18 questions although it does take in the new values.
I am doing something similar in one of my apps but instead of questions I store 2 values for the 12 months of the year.
ClearCollect(colItemsToSave,Gallery3.AllItems);
ForAll(colItemsToSave, Patch('My Data Source', {ID: Value(lblItemID.Text)}, //Hidden ID label { FFActuals:Value(inpActuals.Text), FFForecasted:Value(inpForecast.Text) } ) );
The Patch functions goes as Patch(Datasource, ItemToBePatched, Updates).
Patch can be used to created new records as well is you use it this way:
Patch(Datasource,Defaults(Datasource),{ Property1:"", Property2:Value(input1.Text) })