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 / New Form saves but the...
Power Apps
Unanswered

New Form saves but then shows the last edit results

(0) ShareShare
ReportReport
Posted on by 12

I have a list and have created an integration from Sharepoint to PowerApps.  The new works and saves correctly but after it saves the screen shows the last edited record in the list.  I would use the form.LastSubmit.ID but as this is a new form and last submit only supports Edit mode it does not work.  The rest of the functionality is fine, just this frustrating behaviour(lack of functionality).  So the question, how do I get the ID on a new form save when I cannot use LastSubmit for the reasons above.

 

Thanks in advance

 

Nigel

Categories:
  • eka24 Profile Picture
    20,925 on at

    Another Approach is:

    First(Sort(Datasource,Descending)).ID

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

    Please Subscribe to my Youtube Channel

     

  • Nigel007 Profile Picture
    12 on at

    Hi, 

    Thanks for the speedy reply.  Is that reliable, is there a chance of another update clashing?  Maybe its within my session that its safe, please confirm.  I might use it anyway as the list will likely be low(ish) use.

  • eka24 Profile Picture
    20,925 on at

    It reliable. You can try with different sessions and give a feedback.

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

    Please Subscribe to my Youtube Channel

  • Nigel007 Profile Picture
    12 on at

    So in the new scenario the Id will have a value after save but I need to consider 32

    - pressing new and getting see new after save

    - pressing edit and getting see those details then and after save

     

    ive banged my head on this ide for days thinking of writing it from scratch it’s that hard to debug, and functions seem to be missing. Hope you can bring be back into the power apps fold

  • Nigel007 Profile Picture
    12 on at

    Hi,

    Here is a closer look at what I am doing as its still not working.  I should make it clear, the reason its being difficult and this is not forms out of the box is that there is more to do after saving so I want it to stay on the same page.  On that page after saving the user can walk away and come back another time or straight away submit the form for processing by a manager.  That causes email and more workflow, most of which is working but this part I cannot get working soon will mean I haveto create a new screen where the form is displayed and workflow continues, but this would just more elegant! (currently elegant = very painful and obtuse).

    In AppStart

     

    Set(myID, 0)

     

    Then in SharepointIntegration.OnSave I have,

     

    SubmitForm(SharePointForm1);
    If(
     IsBlank(DataCardValue14.Text),
     Set(
     myID,
     First(
     Sort(
     ResourceRequest,
     Descending
     )
     ).ID
     );Set(ItemData,LookUp(ResourceRequest,ID=myID)) 
    )

     

    The OnSave always calls the Form OnSuccess after where I have no particular code.

    On Visible has no particular code for the screen.

    All editing works, saves etc.

    New get created and saved with an ID correctly, but I cannot get it to stay on the same record, it jumps off to the first record in the list.

     

    Any help appreciated

    Nigel

  • Nigel007 Profile Picture
    12 on at

    Hi,

     

    This solution did not work for me.  I put it into the item element on the form as follows,

     

    If(
     IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),
     LookUp(ResourceRequest,ID = First(Sort(ResourceRequest,Descending)).ID),
     SharePointIntegration.Selected
    )

     

    But it returns the last edited item.

     

    Hoping for another solution.

     

    Regards

     

    Nigel

  • Nigel007 Profile Picture
    12 on at

    One extra point, I think your code could be correct but as my powerapps is a corporate instance the new record is being delayed by about 3-5 seconds.  So when I try to load the 'new' record its not there yet.

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Nigel007 ,

    To capture the ID of a new record you have just created - OnSuccess of the Form

    Set(
     myID,
     Self.LastSubmit.ID
    )

    You can leave it on the Edit function as well as it will simply set the variable to shat it already is.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • Nigel007 Profile Picture
    12 on at

    Warren,

     

    Thanks for the reply.  The Sharepoint integration has OnNew set to NewForm(SharePointForm1).  All the documentation on LastSubmit says it only works on EditForm, this is, I guess to allow it to know the ID of the edited form when it submits and store it in meta data.  Putting that to one side I added your code to my OnSuccess code and then altered the Item code to the following,

    If(
     IsBlank(SharePointIntegration.SelectedListItemID) || 
     IsEmpty(SharePointIntegration.SelectedListItemID),
     LookUp(
     ResourceRequest,
     ID = myID
     ),
     LookUp(
     ResourceRequest,
     ID = SharePointIntegration.SelectedListItemID
     )
    )

    It still saves correctly but the ID selected is still the first item in the list.  I dont think the ID of the new item is there for a second or two.  I really dont want to make the user wait for sharepoint to allocate an ID and store the new record(if thats what is happening) but maybe some timer is my only option.

    Hopefully I just need to alter my code and this will all go away.

     

    Thanks in advance

     

    Nigel

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard