I've been working on creating a PowerApp connected through a SQL Server database. The only thing causing me grief at the moment is the Edit/Submit Form. For some reason whenever I try and update a record in the edit form, and click my button that submits the form, the new data values aren't being pushed to the datasource. The new values stay reflected on the form itself, but the datasource isn't getting the new values. I have messages checking both the OnSuccess and OnFailure actions, but the OnFailure never triggers so I can't be certain what's going wrong here.
Does anyone have any ideas as to what could be the problem? I've tried searching the forums and google, but couldn't come up with anything that helped me fix the issue.
Solved! Go to Solution.
I'm not sure where you are with respect to my suggestions. Have you tried to let PowerApps create the app for you from the make.powerapps.com page using your SQL table as the datasource?
Yeah I think the issue stemmed from trying to still use and manipulate an edit form generated from the read only table. Making a new app prompted me to go back and just try creating a different edit form which generated just fine and allowed me to write with no issues. Thank you for your help!
The OnSelect is just a simple SubmitForm(formname), and the Item is the Gallery.Selected from the previous screen.
Try Lookup(YourDataSource, ID=GalleryX.Selected.ID) and make sure the datasource matches the one listed in the Data Source property of your form and the Gallery name reflects the gallery in which the item has been chosen. If that doesn't work, I suspect that the problem is going to be with the ID field. Try removing it and re-selecting it again from the field list.
Sadly that didn't help save to the datasource. As an aside, is that a better way of populating the Item field in the future instead of the basic Gallery.Selected?
I always use a lookup function as it will always work to identify the correct record in the original datasource. The problem is if the datasource of the gallery is a collection or if it has been reshaped using AddColumns(), DropColumns(), RenameColumns() or ShowColumns(). ( ref. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-table-shaping ) then it is no longer the same as the datasource in the form and a simple Gallery1.Selected will not work. Form datasources must be actual tables and not collections or shaped tables.
If the changes that you made to the edit form still do not work. To troubleshoot where the problem is, delete the form and try again with a new form. Make sure that the ID field and all the other fields in the record populate when you select the record in your gallery. Make sure that you have accounted for any field in your SQL table that is required by it.
Hmm, well I'm not sure what to say because the table I'm using is straight from our SQL Server and I haven't made any changes to the table on the PowerApps end of things.
When I try making a new edit form, all the data fields default to the view display mode (instead of edit) and each field has two text labels, rather than one label showing field name and a text input box for input. This is what happened when I first made the app and I just changed things to fit my needs, but I'm wondering if this hints at a deeper issue with the data connection itself?
Make sure the form mode is set to Edit. That there is a valid datasource and that the Items property of the form specifes the record being edited. If all of these are done right, the form should show data in all of the fields.
You can let PowerApps create your gallery and forms automatically if you go to make.powerapps.com and select SQL from the start from data. Powerapps will make the entire app from your SQL table. You can check out the properties of all of the buttons and forms to make sure you are doing it right.
So my initial problem stemmed from the fact the database table was being seen as read only from PowerApps's end, but after fixing the primary key column that issue is no longer the case. However, the SubmitForm function is still not properly updating the selected record. I've also tried using Patch() and UpdateIf(), but both of these functions throw the same error: that the "Specified record cannot be found. Server response: resource not found."
Do you have any ideas as to what could be the issue? I've been looking at other forum posts that have a similar issue, but none of the responses have seemed to help me.