Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Increment reference number

(0) ShareShare
ReportReport
Posted on by 1,623

Hi

I need help with being able to tell PowerApps to create and increment my reference number, this is a canvas app form and SharePoint Online is my data source

 

User1 will submit a form, but they will select from 1 of 3 screens only. 

If User1 selects Screen1 I'd like to have my reference number display something like this

 

REW-B-00001

 

If User1 completes Screen2 it would be REW-C-00001

 

If the reference number is already REW-C-00001, Then ideally the next number depending on selection could be REW-B-00002

 

Is this possible,  and how can i do this please?

Categories:
  • Tata87 Profile Picture
    Tata87 2 on at
    Re: Increment reference number

    Hi,

    I have a similar issue and would appreciate your help. In my case I have a dropdown filed and trying to have auto incrementing id based on selected value and could look like this.

     

    AA-00001

    AA-00002

    BB-00001

    AA-00003

    BB-00002

    CC-00001

  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Increment reference number

    @Hasnain_Haider 

    Check the 1st page of this thread.  The solution is always at the top of the thread.

  • Hasnain_Haider Profile Picture
    Hasnain_Haider 19 on at
    Re: Increment reference number

    Plz send a link

  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Increment reference number

    @Hasnain_Haider 

    Please start a new thread.  This one has already been solved.

  • Hasnain_Haider Profile Picture
    Hasnain_Haider 19 on at
    Re: Increment reference number

    REW-B-00001

    REW-B-00002

    REW-C-00001

    REW-B-00003

    REW-C-00002

    I Want this ,how create this type of data command

  • Lefty Profile Picture
    Lefty 1,623 on at
    Re: Increment reference number

    @mdevaney 

     

    Thank You 😀

  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Increment reference number

    @Lefty 
    Did my my suggestion work for you?  Please let me know.

  • mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Increment reference number

    @Lefty 
    Yeah, sure thing.  Just let me know if it works or not 🙂

  • Lefty Profile Picture
    Lefty 1,623 on at
    Re: Increment reference number

    @mdevaney 

    Thank you very much, I will try this out, either today or after the Easter break and report back, but your instructions are very precise, so I expect this will work, I will mark it answered once I've tested, if that's okay?

  • Verified answer
    mdevaney Profile Picture
    mdevaney 29,987 on at
    Re: Increment reference number

    @Lefty 

    Very good question!  The data will be populated by PowerApps.

     

    However, I had not considered what would happen if there was no data to start.  The code I provided should be modified like this...

    Set(nextSequenceNumber, First(Sort(your_datasource_name, SequenceNumber, Descending).SequenceNumber;
    Patch(
     your_datasource_name,
     Defaults(your_datsource_name),
     {
     ReferenceNumber: "REW-B-"&Text(nextSequenceNumber, "0000"),
     SequenceNumber: If(!IsBlank(nextSequenceNumber),nextSequenceNumber, 0)
     }
    );

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,304

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard