Jon Lake
asked on
Update SharePoint list item using O365 PowerApp
I need the correct method/code to support updating a SharePoint list item/record when a user clicks a button in an O365 PowerApp.
I have a list hosted in SharePoint that is made visible to users via an O365 PowerApp. The app is very simple in design, with a table and a cancel button. So far, when the user selects an item/record the ID of that item/record is populated into a field to the right of the cancel button. I did this believing that it should be passed to the code in order to update the correct record. Here is a screen shot of the PowerApp (using test data):
If the user has an item/record selected, when they click the 'Cancel submission' button I need the status field in the SharePoint list to update (for the item/record) to read 'Cancel', and for the list visible on the form to refresh.
So far I've failed to come up with the correct code syntax, which may be because it's not possible but I suspect that as a newbie to PowerApps I'm missing some fundamentals...here is where I have got to (under the OnSelect):
Patch(tbl_funds_due_in,{tb l_funds_du e_in ID: DataTable1.Selected.ID},{r eceived: "Cancelled"})
I have a list hosted in SharePoint that is made visible to users via an O365 PowerApp. The app is very simple in design, with a table and a cancel button. So far, when the user selects an item/record the ID of that item/record is populated into a field to the right of the cancel button. I did this believing that it should be passed to the code in order to update the correct record. Here is a screen shot of the PowerApp (using test data):
If the user has an item/record selected, when they click the 'Cancel submission' button I need the status field in the SharePoint list to update (for the item/record) to read 'Cancel', and for the list visible on the form to refresh.
So far I've failed to come up with the correct code syntax, which may be because it's not possible but I suspect that as a newbie to PowerApps I'm missing some fundamentals...here is where I have got to (under the OnSelect):
Patch(tbl_funds_due_in,{tb
ASKER
Hi, I'm sorry but the suggested syntax is still presenting as an error:
The SharePoint list has an ID field, created sequentially and automatically by SharePoint, and is the primary and key identifier for the record. I believe that I need to pass that, or use that to update the field called Status in the correct record. My thought process has been that I should be able to use submission_list.Selected.ID or refer to a hidden field called id_num, which is populated by submission_list.Selected.ID.
The SharePoint list has an ID field, created sequentially and automatically by SharePoint, and is the primary and key identifier for the record. I believe that I need to pass that, or use that to update the field called Status in the correct record. My thought process has been that I should be able to use submission_list.Selected.ID or refer to a hidden field called id_num, which is populated by submission_list.Selected.ID.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Jon,
Of course, ID is a required field, I wonder though the syntax you have mentioned in your last commend would work as it is.
Anyways I am glad it got sorted out.
Also current record can be existing record retrieved OR it can be a new record - Patch works for both.
Regards,
Chinmay.
Of course, ID is a required field, I wonder though the syntax you have mentioned in your last commend would work as it is.
Anyways I am glad it got sorted out.
Also current record can be existing record retrieved OR it can be a new record - Patch works for both.
Regards,
Chinmay.
You are on a right track. Patch is the way to go. We have been working with such apps for a while now, what I would recommend is to check the following:
1. You must have a record that you will send in as part of your Patch
2. Check Metadata names of your SharePoint list, this one has trumped many experienced developers.
3. In the code editor, if everything you have written is fine then Format text button will be enabled.
Also, from the documentation
Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])
Here is a sample for your reference:
Open in new window
In your code, you are trying to update two records, it should be one packet in curly braces.
Regards,
Chinmay.