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

sharepoint list based unique case reference number with consistency

is there a way to use flow based solution on sharepoint list where a new entry in the list can generate a unique case reference number which will get incremented by one, but still with some consistency checks like, if an entry is deleted, the numbering is not reused? 

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

The easiest way to do that is to sort the list using ID in descending order and take the first record.  That will give you the last ID used.  Add 1 to that and incorporate that number when creating the new record and you'll have a unique reference number where numbers are not reused.  The only concern would be if two records are created at essentially the same time after reading the highest ID.  You could then have two records.  But reading the highest ID just before creating the record would minimize the time gap where that could happen so unless the system is heavily used you would be OK.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Jared_Simon
Helper I
Helper I

Thanks - I will test that. not much concerned about two users hitting submit same time as i don't expect that kind of traffic. is there a way to reset the ID to 1 after all tests?

You can only reset the ID on the SharePoint list by deleting and recreating the list.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
PompusMaximus
New Member

Use a "When Item is Created" trigger.

Add your list info.

 

Then for your reference number field, insert this function:

 

concat('LFV',formatNumber(triggerOutputs()?['body/ID'],'000000'))


The LFV is a header that can be whatever you make it.  The '000000'  is how many numbers you want to default showing.  The ID field is being used as the number generator and will always increase by one.  The only issue I've found is there is about a 30 second delay or so for the SharePoint list to update the field but it works.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

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.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (2,020)