web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issue just today with ...
Power Apps
Answered

Issue just today with saving an EditForm after selecting an item from a Gallery

(0) ShareShare
ReportReport
Posted on by 77

I have an app that has been working fine for months now. Today I noticed it isn't saving new records properly. The configuration for this part of the app is a little complex: a gallery listing items, and a NewForm button, which leads to an EditForm page that just does a SubitForm() to save the data. However the edit form has OnSuccess() code that correctly stores the relational link/ID of the selected gallery item (a workaround I got from here to deal with linking SharePoint lists properly):

 

Patch('Exp Behaviour 2', Last('Exp Behaviour 2'), {Animal_rel0:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id:Gallery_Animals.Selected.ID, Value:Gallery_Animals.Selected.Title }} ));

Today when trying to save new entries the app isn't storing this linked value properly, after the first entry I make. So, for example, I made one new entry after selecting a gallery item, and that works fine. Then I select a different gallery item, go to the NewForm, put in data, save it, and now it saves the relevant/current Animal_rel value to the prior record in the SharePoint list - not the latest/relevant record, which is left blank. Therefore it seems like the Last() function used in the code above is not returning the actual last record saved, but the one before. However, it is strange that the first new entry I make today works fine (i.e. it is weird that it isn't also trying to save the Animal_rel value to the prior entry in the list).

 

Nothing has changed in my app recently so it must be due to a backend change on the MS end. Any ideas?

 

Edit: I realised this could be a '500 item limit' issue with SharePoint lists. The list ID is up to 552 but isn't contiguous, so the list is likely ~500 items big - I couldn't see how to get a count. How can I get around this in this case?

Categories:
  • Verified answer
    v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @sfishe,

     

    Instead of using the last () function, please take a try to switch to:

    EditForm.LastSubmit

    The whole formula should be:

    Patch('Exp Behaviour 2', 
    EditForm.LastSubmit, 
    {Animal_rel0:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id:Gallery_Animals.Selected.ID, Value:Gallery_Animals.Selected.Title }} ));

    Read more here:

    "

    LastSubmit – The last successfully submitted record, including any server generated fields.

    • This property applies only to the Edit form control.
    • If the data source automatically generates or calculates any fields, such as an ID field with a unique number, the LastSubmit property will have this new value after SubmitForm successfully runs.
    • The value of this property is available in the OnSuccess formula.

    "

    Reference.

     

    Regards,

    Michael

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard