cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

After Pacth select the last record

Hi there,

 

My patch function duplicate a record, but when finish the record in the editform is the original record that I used to pacht and I want to see the new one.

 

I have in the same screen, the editform and a table.

 

The edit form in Item propety is "DataTable.Selected":

 

Screenshot_1.png

 

Thanks.

22 REPLIES 22
Super User III
Super User III

Hi @Manarjomar ,

With that Items property

DataTable.Selected

you will always see the last selected record.

One option is to do the following (assuming you have a SharePoint back end)- on the OnSelect of the gallery

Set(vID, ThisItem.ID)

The Items of your form

Lookup(
   YourListName,
   ID=vID
)

On the OnSuccess of your New form

Set(
   vID,
   YourFormName.LastSubmit.ID
)

This should then display the record you have just created.

 

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.

Similar to @WarrenBelz solution, you could put the entire selected record in a variable. You can then access the current selected gallery item from the variable.

 

So Gallery OnSelect would be:

 

Set(varSelectedRecord, ThisItem)

 

Items of form would be:

 

varSelectedRecord

 

Form OnSuccess:

 

Set(varSelectedRecord,LookUp(YourListName,ID=varSelectedRecord.ID));

Thanks @Digital ,

Yes that will certainly work (and this is just a personal preference), but I generally present the actual record for the SubmitForm() function rather than a copy of it (which is what the Variable is).

That’s a very good point! 

@Digital  and @WarrenBelz , thank you , but I tried both option and I can't see the last record.

 

I understand yor functions  and the syntax, I changed the table for a gallery (to have the OnSelect propety), hoveaver, the last record is not selected and neither show in the editform.

 

My datasource is a SQL database, but I don't think that is the problem.

 

Another idea?

 

Thank you

@Manarjomar ,

My answer was for SharePoint. It is very useful to post your data source with a question as this will often determine the strategy. Do you have a unique identifier in your data source as this is the value you need to use. You simply need to find this number (and LastSubmit will retrieve this) and base the Item of the form as a Lookup on this. The one thing I probably left out is a refresh of the data source before going to the display form.

 

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,

 

Yes, I forgot tell my data source.

 

I have "Id" field with identity.

 

I try the refresh (last submit and in on success propety) but nothing happen.

 

I'm thinking to try with Default propety of gallery, but I don't know what function I can use there to show the lastsumited record.

 

Thank you.

Thanks @Manarjomar,

There is another way, but there is a risk of two users posting very close together on this. You find the highest ID in the list.

First(
   Sort(
      YourListName,
      Id,
      Descending
   )
).Id

Although LastSubmit() should be able to get this value.

 

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.

@Manarjomar 

 

if you use patch instead of submit, the last submit doesn’t help. I had the same problem. 

 

The solution:

 

Set(varNewID, Patch(SharePointList, Defaults(SharePointList),{...}).id)

 

and then set your item for your gallery or whatever to this

varNewID

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

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

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (42,778)