web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create a Unique Refere...
Power Automate
Unanswered

Create a Unique Reference Number

(0) ShareShare
ReportReport
Posted on by

Hi, good day! i just want your expert opinion and help about this flow, this is already running but i think there must be a better way.

 

I am writing to explain the Power Automate flow that I have created for generating unique reference numbers based on the service requested by the user.

 

The purpose of this flow is to allow users to create a unique reference number for their requested service. The reference number is generated based on the service they selected, and it follows a specific format.

 

For example, "FMA-TT-YYYYMM-00000" is used for the Trip: Driver and Service Vehicle service, "FMA-MS-YYYYMM-00000" is used for Messengerial service, and "FMA-UA-YYYYMM-00000" is used for Utility Assistance.

 

The flow begins by checking the service that the user has requested and setting the format of the reference number accordingly. It also checks if the created date is the same as the current year and month (YYYYMM). If it is not, the reference number will reset to 00001. If the created date is the same, the flow will get the last recorded reference number and add 1 to it.

 

For example, suppose there are three recorded reference numbers: 00001, 00002, and 00003. If we delete 00002, the next ticket will be 00004. Similarly, if we delete 00001 and 00002, the next ticket will be 00003.

 

If the reference number is empty, the default value will be set to 0001. Moreover, the flow will check if the reference number already exists. If the reference number already exists, it will enter a loop to generate a unique reference number.

 

Finally, the flow creates an item as the last step.

In conclusion, this Power Automate flow allows users to generate unique reference numbers based on their requested service. It ensures that the reference numbers are formatted correctly and are unique for each request.

Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at

    Since you are just asking for opinions, I think what you are trying to do is overly complicated. I don't know how you will keep track of the incrementing number that will be part of the ID if you need to take into consideration deleted items. I am assuming that your flow runs when the item is created, so I am not following why you need to check if the current year and month is the same as the created date. How could it not be? If it is because you want the numbers to start over each month at zero, again, that is going to be very complicated. I would assess how beneficial that really is.

     

    To greatly simplify what you want to do, I would use the ID of the list item for your unique reference number. In SharePoint, the ID is basically a primary key and can never be used again. If an item is deleted, it will automatically create the next item with the next logical number. You can easily format the ID with leading zeros with the following expression:

     

     

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

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard