Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Lock, Block or time delay a flow for Document generator

(1) ShareShare
ReportReport
Posted on by 30
Hi All
I have built a document number generator that works fine except sometimes it will end up with two documents with the same number.    The generator works by either a new item trigger in a List or a new item via a power app. 
I have 2 lists, 
1, MasterDataList.
2, RefGenList (1 tem list with the last document number is stored).
 
This is the basic order of the flow:   
New item in MasterDataList >Trigger(RefGenFlow) > Get Item (last DocNumer from RefGenList) > Increment DocNumer > Concat DocNumber with prefix (ie REF000123) > Update Item (New DocNumer back into RefGenList) > UpdateItem into MastDataList.
 
I'm guessing that concurrent new Items are running, and in between Get Item (DocNumber) > Increment > Update Item, the other new item is swooping in and grabbing the same Doc Number.
 
I have updated my flow to Get > Increment > Update successively to try and reduce the chances of double-ups but I am concerned it is not enough. 
 
Soooooooooooo
1, Is there a better method for this than what i am doing?
2, Im Pretty sure i cant lock the item in the list (other than change privileges) can i Lock the flow so others can't trigger it until i have finished?
3, Time delays the flow, ie when I 1st trigger it cant be retriggered for say 20ms (should be enough)
 
Any suggestions would be greatly appreciated.
 
I have a fair bit of experience in microprocessors and real-time operating systems, so dealing with timing issues is almost number 1 in that environment.  Just not sure how to tackle it here.
 
Cheers Anthony
  • Suggested answer
    HC Sol Profile Picture
    30 on at
    Lock, Block or time delay a flow for Document generator
    Encase anyone trips over this post.  I have set the concurrency on my Flow to 1.  This is working at the moment.  Not sure if this is the ultimate solution but it's working for no.
  • Suggested answer
    WillPage Profile Picture
    1,919 on at
    Lock, Block or time delay a flow for Document generator
    If the Document ID service isn't enough and you don't want to use the list item ID of the doc library, then the best you can probably do to avoid a race condition is to have a separate list for tracking the numbers. Flow is triggered -> first thing you do in the flow is create an item in the tracking list. The response from the create item action will contain the list item ID so you can use that as your document ID. You can add an arbitrary number to it afterwards so it lines up with your existing document IDs and do the concatenation etc. That way there's no dwell time between getting an item and creating a new one for a race condition to occur. You can delete the item to keep the list empty if you like, IDs don't get re-used.
  • HC Sol Profile Picture
    30 on at
    Lock, Block or time delay a flow for Document generator
    Hi Again
    I have looked into this solution and dosent suit my clients needs.  Then need to generate a sequential number per Job (Job Number).  Not a doc number for every doument on the site.  Each item in MasterData list will represent a Job thus a vaild Job Number.
     
    Other people must do the same.  A ticketing system will need a sequentiql number generator.  There must be a better solution out there.
     
    BTW you cant take the last number in the MasterData list and add to it as the same issues apply, also if someone deletes an item i want the JobNumber to die with it.
     
    Cheers
     
  • HC Sol Profile Picture
    30 on at
    Lock, Block or time delay a flow for Document generator
    thanks i will look into this.
     
    Is this different to the standard ID that is created in the list.     Because i have tried using the list ID and had a few peoblems with it.  Several people on this forum advised againt using the List ID.
     
     
  • WillPage Profile Picture
    1,919 on at
    Lock, Block or time delay a flow for Document generator
    You might be OK just using the document ID service in SharePoint. Enable in Site collection features then configure in Site settings -> Document ID settings:

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >