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

How can I load latest record of SharePoint list in editform on click of the button?

Hello,

 

I have created and app connecting to SharePoint list using standard app template, where browse screen gallery control display latest records that can be updated by clicking on individual item, however I have one standard button on the same form called "Update Latest Record" - How can I redirect to the edit form that allows me to edit latest record on the click of the button?

 

Can you please help?

 

Thanks!

8 REPLIES 8
Super User III
Super User III

Hi @PowerApper25 ,

You can get the last record with this in the Item of the Edit Screen

Lookup(
   YourListName,
   First(
      Sort(
         YourListName,
         ID,
         Descending
      )
   )
)

 

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.

This formula does not load latest item in the EditForm as it throws following error:

 

2.png

 

Any clue?

 

Thanks,

Hi @PowerApper25 ,

Not on my PC at the time - you just need

First(
   Sort(
      YourListName,
      ID,
      Descending
   )
)

 

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.

@WarrenBelz 

 

Now, It works for First(Sort('listname',ID,Descending) on item property of editform.

 

However, with If, condition [ If(RecordType=2,First(Sort('listname',ID,Descending)),BrowseGallery1.Selected) ] it doesn't execute when RecordType=2, Also it does not throws any error.while only First(Sort('listname',ID,Descending) works!

 

How can I make working with this condition on item property?

If(RecordType=2,First(Sort('listname',ID,Descending)),BrowseGallery1.Selected)

 

Thanks,

Hi @PowerApper25 ,

Maybe something like the below - you need a Record filter on the second bit as well. If this is a gallery, you would use Filter.

If(
   RecordType=2,
   First(
      Sort(
         'listname',
         ID,
         Descending
      )
   ),
   Lookup(
      'list name',
      ID = BrowseGallery1.Selected.ID
   )
)

 

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.

For me concern is,

 

First(Sort('List',ID,Descending)) - It works, but doesn't work if added in IF/Switch formula

BrowseGallery1.Selected - It works, independently, also if added in IF/Switch Formula.

 

Therefore, formula mentioned with IF condition is not being executed as stated earlier 😞 not sure why!

Hi @PowerApper25 ,

 

That's wired. I just made a test, the formula logic should work well.

How do you define 'RecordType'? I suggest you hardcode the RecordType to check if the issue is from RecordType.

 

If(2=2,First(Sort('listname',ID,Descending)),BrowseGallery1.Selected)
or
If(1=2,First(Sort('listname',ID,Descending)),BrowseGallery1.Selected)

 

Sik

Hi @PowerApper25 ,

I agree with @v-siky-msft and also tested it here.

Can you please send as text the exact code that is failing.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (95,523)