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
Community Champion
Community Champion

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
Community Champion
Community Champion

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

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,909)