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

ForAll patch sequence numbers issue

Hi All,

 

I am having some issue in duplicating and patching records multiple times using different browser or different user doing the same operation at the same time. It works fine when duplicating 1 record at time or using same browser however issue occurs when using different browser or different users at the same time, it starts repeating application number. e.g. let's say last saved record number is SW-00082 and I need to duplicate 5 records but at the same time different user trying to do same thing on different record, that's when it start repeating please refer below example.

 

 

asif082_1-1642477765175.png

 

 

Below is code. 

 

asif082_0-1642474638504.png

If anyone can help me with above issue that would be great please.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @asif082 ,

You need some reference number, whether it be CountRows or a stored number that each user will see when they open the record. The process then actions according to the information they have at that time. As I mentioned, you could refresh or requery to shorten the "window", but ultimately two users within a few seconds of each other will action the same information.

 

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

View solution in original post

9 REPLIES 9
cwebb365
Super User
Super User

You'll need to utilize you primary id key for the table for the entries and at the end of the patch get the return id value, then process the Generated ID from that. This way you get a unique ID on the insert to utilize. Trying to generate the ID from code at runtime doesn't let the other clients know about them. 

 

So you can return the ID into a variable or something. with onclick you can do Set(varInsertedID, Patch(logic).ID), then use that varInsertedID to generate the ID and update using the above logic. So generate the base record, return ID, generate ID from math on that ID then Patch again to update with the new ID etc. and continue.   

 

WarrenBelz
Super User
Super User

Hi @asif082 ,

You cannot avoid concurrent duplication on sequential numbers if the second user queries the data before their list is refreshed following the updating by the first user. You could put Refresh(SW_Details_Test) before the patch but this will not completely eliminate the possibility of it happening.

 

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

 

 

Thanks Warren, what I am trying to do is dynamically duplicating records with new application ID, so in other words whatever user type the value it creates duplicate records with new application ID. 

 

asif082_0-1642499570540.png

 

 

 

Thanks cwebb365. The problem is auto generated SQL ID is not helpful in current situation. As per business requirement I need to use custom application number  e.g. SW-00001, SW-00002, SW-00003 etc and there are multiple locations using this application. So, one of the requirement is asking user to duplicate record dynamically by entering value. so if user enter 8 as a value and click yes then using last store application number it add plus 1 and so on 8 time according to below.

 

asif082_1-1642501745958.png

 

I am still confused how I achieve above. Any help would be really helpful.

 

Thanks

 

Hi @asif082 ,

I am not sure how to respond further - concurrent use of this (although the window should only be seconds) will create duplicates.

So, any solution or possible work around to avoid duplicates? I have tried first patching without Application number and storing records into collection and then patching that collection and then assigning Application number to unique id but still no luck.

Hi @asif082 ,

You need some reference number, whether it be CountRows or a stored number that each user will see when they open the record. The process then actions according to the information they have at that time. As I mentioned, you could refresh or requery to shorten the "window", but ultimately two users within a few seconds of each other will action the same information.

 

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

Again, you have to rely on generated id from the backend. You return that THEN generate your custom number. So when you generate your ID, you plug the ID in and add or subtract that value to meet you're needs, but it has to base off that number to keep uniqueness, no other way. Or you can use a Table to do the same thing as well where you "Generate" a code and return it as well. But either way, you cannot use your app to generate the ID you have to have a transaction take place in a central location. 

asif082
Helper II
Helper II

Thanks you guys, really appreciate your help 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,198)