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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Increment for Prefexi ...
Power Apps
Answered

Increment for Prefexi number

(0) ShareShare
ReportReport
Posted on by 16

Hi,

I created a form for people to get a register number looks like: ABC001, ABC002.... each time, when they use a form to record something, they will get a new auto increment register number. What I have done is: 

1. Set variable in Screen Onvisible: Set(LastRef,Last('Sharepoint List').Reference)

2. In the form, in the reference Datacard, Default: If(Form3.Mode=FormMode.New,"ABC"&(Last(Split(LastRef,"ABC")).Value*1)+1,Parent.Default)

 

Then, every time when people create a new form, the reference is the last number+1.

 

But I have a concern, if someone created a new form, then he left it and go to do something else, so he will get a form with a reference number say: ABC017. At the mean time, another person created another new form, the form will also provide ABC017 as the last number in the sharepoint list is ABC016. So if both at the end, created the recode, I will have 2 X ABC017 in the sharepoint list. 

 

How can I solve this problem? Because only a unique number should be issued to one person. 

 

Thanks. 

Categories:
  • Verified answer
    developerAJ Profile Picture
    4,763 on at

     

    Default: If(Form3.Mode=FormMode.New,number,Parent.Default)

     

    Use this

    Refresh('Sharepoint List')

    Set(number,"ABC"&(Last(Split(Last('Sharepoint List').Reference,"ABC")).Value*1)+1)

    set variable on button click just before submitting form. This will decreased the occurence by a lot because a button may not be clicked by individual at same time.

     

    if both users click the button at same time we cant do anything apart from making the column unique values as Yes in sharepoint. in that case it will throw an error to one of user.

     

    Please click Accept as solution and Thumbs Up. 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.

     

  • YutingHe Profile Picture
    16 on at

    Thanks @developerAJ .

     

    This doesn't solve my problem. My problem is not people click the button at the same time. The problem is a number is generated when someone create a new form. Some when someone created a new form, he will get a number which is the last number in sharepoint list +1. But if this person open the new form, and he didn't complete the form and start to do something else for about few hours. Then he come back to complete this form and submit. During this few hours, somebody else came and create another new form, but the new form will not know that someone already took the last number +1, so the new person will also get a new form with a number which is the last number +1. At the end, 2 people will both get exactly the same number which is: last number +1. 

  • developerAJ Profile Picture
    4,763 on at

    I understood your issue your problem will get fixed by making suggestion I mentioned

     

    i am also saying that my suggestions also might create an issue if both people click button at same time

  • YutingHe Profile Picture
    16 on at

    Thanks @developerAJ, that's really helpful. I have amended my app and understand that a new number will be generated only when someone click the submit button.  To increase the user experience, it will lead to another improvement. When someone created a new form and get a new number, after they submit, it will navigate them into to successful page(OnSuccess) to say: Tom Smith, your Number is: ABC XXX. But when someone is editing the existing recode, after submit, I want to navigate to screen 2 to say: your recode is updated.  I understand that after submit form, the form mode is automatically set to Edit. So I can't use If function to navigate to different screen just by formMode.  So how can I navigate to different page? 

  • YutingHe Profile Picture
    16 on at

    Thanks @developerAJ , I have worked it out myself by setting a variable in the submit button to store the Form Mode.  It all works! 

  • developerAJ Profile Picture
    4,763 on at

    Glad to Hear

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard