cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vstar19
Helper V
Helper V

Power Apps Edit Form updating wrong SPO List item

Hello

 

I have a SPO List. 

I have used a gallery to show the list item and then used the > to link each item to an edit form. Navigate('EditPage)',ScreenTransition.Cover) - This works fine. It correctly loads the item and allows the user to make an edit. 

 

I tried to edit an item and it worked fine. Then i went back in and tried to edit another item, and for some reason, it edited a different SPO List item

 I have a save button, here is my code 

 

Patch(
'DataSource',
gal_allworkspaces.Selected,
{
'Primary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue34.Selected.Claims,
DisplayName: "",
Email: DataCardValue34.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{
'Secondary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue35.Selected.Claims,
DisplayName: "",
Email: DataCardValue35.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{Status: {Value: DataCardValue40.Selected.Value}},
{
WorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
{Value: "Yes"}
)
},
{
DateWorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
Now()
)
}
);
Navigate(
Confirmation,
ScreenTransition.Cover
)

 

The issue is really DataCardValue40.  If a user goes in and selects Sign then clicks Save. PowerApps updates a different item. It worked OK for me one one list item, but when i tried to edit another list item - it didnt work. 

 

I am really confused. Can anyone help?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Nogueira1306
Super User
Super User

Hey! Why dont you try a LookUp instead of Gallery.Selected ?

 

Patch(
'DataSource',
LookUp('DataSource', ID = Gallery1.Selected.ID),
{
'Primary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue34.Selected.Claims,
DisplayName: "",
Email: DataCardValue34.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{
'Secondary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue35.Selected.Claims,
DisplayName: "",
Email: DataCardValue35.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{Status: {Value: DataCardValue40.Selected.Value}},
{
WorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
{Value: "Yes"}
)
},
{
DateWorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
Now()
)
}
);
Navigate(
Confirmation,
ScreenTransition.Cover
)

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!



Last Post on Community

View solution in original post

C-Papa
Super User
Super User

This is because when you use gal_allworkspaces.Selected and a item is edited or created, regardless if you are on a different screen, the gallery will refresh which changes you selected it to the top item in the gallery. 

 

with the gallery button which moves you to the form screen add, Set(Var_Selected_Item,ThisItem), then set your form items to Var_Selected_Item and change gal_allworkspaces.Selected in your patch to Var_Selected_Item. this should fix the issue of the gallery refreshing as the record is stored in a variable 

View solution in original post

4 REPLIES 4
Nogueira1306
Super User
Super User

Hey! Why dont you try a LookUp instead of Gallery.Selected ?

 

Patch(
'DataSource',
LookUp('DataSource', ID = Gallery1.Selected.ID),
{
'Primary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue34.Selected.Claims,
DisplayName: "",
Email: DataCardValue34.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{
'Secondary Owner': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandUser",
Department: "",
Claims: DataCardValue35.Selected.Claims,
DisplayName: "",
Email: DataCardValue35.Selected.Email,
JobTitle: "",
Picture: ""
}
},
{Status: {Value: DataCardValue40.Selected.Value}},
{
WorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
{Value: "Yes"}
)
},
{
DateWorkspaceAgreementSigned: If(
DataCardValue40.Selected.Value = "Signed",
Now()
)
}
);
Navigate(
Confirmation,
ScreenTransition.Cover
)

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!



Last Post on Community

C-Papa
Super User
Super User

This is because when you use gal_allworkspaces.Selected and a item is edited or created, regardless if you are on a different screen, the gallery will refresh which changes you selected it to the top item in the gallery. 

 

with the gallery button which moves you to the form screen add, Set(Var_Selected_Item,ThisItem), then set your form items to Var_Selected_Item and change gal_allworkspaces.Selected in your patch to Var_Selected_Item. this should fix the issue of the gallery refreshing as the record is stored in a variable 

You are an absolute life saver. Thank you so much for helping me on this. It works now 🙂

Thank you so much. I fixed it using the LookUp, above. 

But this is an alternative way to resolve the issue - thank you for sharing and i will defo use this approach. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,138)