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 Apps / Power Apps - Assigning...
Power Apps
Answered

Power Apps - Assigning Auto number for Purchase Orders

(0) ShareShare
ReportReport
Posted on by 95

I am creating a purchase order app for my company.  I created a SQL table to hold all the purchase order numbers to be used in sequence so it will auto assign the PO number.  When the user clicks on the gallery for the next number, I run code to update the table with a flag that it is locked and cannot be used by another and filter my gallery based on that flag.

 

Issue I am running into is when there are multiple users going in the flag does not always get caught in time and each user will use the same number.

 

Anyone have a way to assign the numbers properly while having multiple users in the app creating purchase orders?

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @etroy333 

    It is really a question of at what point the PO number is assigned.  Normally, there would be an Edit form in new mode to create a new record.  If you were editing records in a gallery, typically the PO number would already be assigned. If you were using an edit form, then the Update property of the card would  be First(Sort(Table, PONumber, Descending)).PONumber + 1  and the number would be assigned at the moment the form is submitted.

     

     

     

  • etroy333 Profile Picture
    95 on at

    I need the PO number to be assigned as soon as someone chooses to create a new PO.  Before they fill out and submit.  The way I have it works fine if there is only one person creating them, when a 2nd person goes in and selects a PO Number from the gallery that gallery is not always refreshed yet and they will select the same PO number.  

     

    My PurchaseOrder table has a unique number id when the po is inserted for the PK, but we are wanting a specific set of numbers for the number assigned going to the supplier.

  • etroy333 Profile Picture
    95 on at

    Do you think if I create an added identity column in the table starting with that set of numbers we want to use then not even have them see the number until after creation would work?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @etroy333 

    That sounds good.  I still don't know if you are using an edit form to create the record but if you are, you can put 

    Notify("Your new PO number is: "& Self.LastSubmit.POnumber &" Please make a not of it", Success, 0) 

    in the OnSuccess property of the form. The "0" will keep the message on the screen until the user dismisses it. 

  • etroy333 Profile Picture
    95 on at

    Sorry, not I am not using a form. Due to the Header and line combo, I am just using fields and a Patch to create new rows in the table

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @etroy333 

    Then I would suggest the following immediately after your patch

    ;If(
     // check if there were any errors when the patch was submitted
     !IsEmpty(Errors(sqltable)),
     // if true, show any error message
     Notify(
     "You submission failed",
     NotificationType.Error
     ),
     Notify("Your new PO number is: "& Self.LastSubmit.POnumber &" Please make a not of it", Success, 0) 
    )
  • etroy333 Profile Picture
    95 on at

    Oh thank you.  That will help with the user knowing the PO number upon submission.  

  • mmollet Profile Picture
    3,187 on at

    You could always Patch an essentially blank value to your table while using defaults as the 2nd paramerter in that call. This would return a blank object escept for defaults that it put in for you as well as it would have the auto-generated guaranteed unique ID that was made server side. The object retured would have the ID of the new entry and you could then use that to edit it and take as much time as you want as the 2nd patch after the user inputs data would be simply editing that original entry. The original entry would just be 'reserving' its unique ID number handed out to it. This way there is no way for users to get the same number no matter what.

  • Verified answer
    etroy333 Profile Picture
    95 on at

    Found a way:  

     

    Created a separate table with an identity column starting at the number I wanted. 

     

    Button to move to the screen to fill out the purchase order information has a patch to create that PO number record. Use this to populate the PO number field on the next screen.   

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard