cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

Patch SharePoint List then get last ID doesn't works correct

Hi,

 

I'm using Patch to update a SharePoint List.

After saving the list, I want to call a flow with the just created List ID as parameter.

Unfortunately I don't get the new created ID: I get the ID the second last ID.

 

So my code is:

Patch(
    TestList,
    Defaults(TestList),
    Form1.Updates
);

Set(varID,Last(TestList).ID);

 

I also already tried to set a "Refresh(TestList)" in between, but it didn't solved the problem.
If I use the same function in really small Apps, it works fine. So maybe it depends on the size of the SharePoint List?

My last option would be to use UpdateForm/LastSubmit, but that would force me to "redesign" many steps.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Patch SharePoint List then get last ID doesn't works correct

Hi @max81 ,

 

 

I think this should work for you. It can not only complete the patch function but also save the ID of the current patched record in the variable

 

Set(varID, Patch(TestList,Defaults(TestList),Form1.Updates).ID)

 

Sik

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Patch SharePoint List then get last ID doesn't works correct

Hi @max81 ,

Have you tried

Patch(
    TestList,
    Defaults(TestList),
    Form1.Updates
);
Refresh(TestList);
Set(varID,Last(TestList).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.

Highlighted
Advocate V
Advocate V

Re: Patch SharePoint List then get last ID doesn't works correct

Hi @WarrenBelz : yes, I tried. But without success.

 

I also tried:

Patch(
    TestList,
    Defaults(TestList),
    Form1.Updates
);
Refresh(TestList);
Set(varID,Last(TestList).ID);
Refresh(TestList);
Set(varID,Last(TestList).ID);

 

Also without success. 

My workaround: first make an Submit with just the required field, than use LastSubmit to get the ID then Patch the missing fields.
But I still hope that there is a solution...

Highlighted
Super User
Super User

Re: Patch SharePoint List then get last ID doesn't works correct

Try
Patch(
TestList,
Defaults(TestList),
Form1.Updates
);
Refresh (TestList);
ClearCollect(MyTest,TestList);
Set(varID,Last(MyTest).ID)
Highlighted
Super User
Super User

Re: Patch SharePoint List then get last ID doesn't works correct

Hi @max81 ,

The reason I did not mention LastSubmit was that you were using a Patch instead of SubmitForm, which triggers that value.

Going back to your original post, you mentioned calling a Flow. You can return as (generally), the last item a value to Power Apps which can be the ID of what you have posted, however the posting would have to be from the Flow, not the Patch. This also uses a Flow quota which from what I see would be unnecessary simply to write data to a list.

You could also consider a (hidden) timer after the refresh for (say) five seconds before you do the Collect.,

 

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.

Highlighted
Community Support
Community Support

Re: Patch SharePoint List then get last ID doesn't works correct

Hi @max81 ,

 

 

I think this should work for you. It can not only complete the patch function but also save the ID of the current patched record in the variable

 

Set(varID, Patch(TestList,Defaults(TestList),Form1.Updates).ID)

 

Sik

View solution in original post

Highlighted
Advocate V
Advocate V

Re: Patch SharePoint List then get last ID doesn't works correct

@v-siky-msft perfect. I didn't know that.

 

@WarrenBelz thanks also for your help.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

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.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,495)