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 / Auto Increment in form...
Power Apps
Unanswered

Auto Increment in forms Power Apps

(0) ShareShare
ReportReport
Posted on by 85

Hi everyone,

 

I am having difficulties in creating an auto increment which starts with prefix.

In the picture below, I wanted to make if the user choose the radio button such as Electronic, the part number will increase 1, which is it will be "E-000005".

Az8PnG_2-1690266069072.png

I want to make it increment 1 based on the latest part number according to their Stock Type in database (as picture)

Az8PnG_3-1690266151341.png

This is my code for:

1. OnChange radio button:

UpdateContext({varSelectedStockType: Radio2.Selected.Value});
UpdateContext({varPartNumber: LookUp(Sort(Filter(Samples,'Stock Type'= varSelectedStockType),'Part Number',SortOrder.Descending),true,'Part Number')});

 

2. Default text input:

Concatenate(Left(varSelectedStockType,1),"-",Text(Value(Right(varPartNumber,Len(varPartNumber)-2))+varCounter,"000000"))

 

3. On Select Save button:

SubmitForm(Form3);ResetForm(Form3);
Set(varCounter, varCounter + 1)

 

Any help would be very much appreciated 😁

Thanks in advance!

 

 

 

 

Categories:
I have the same question (0)
  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @Az8PnG ,

     

    We create Dataverse below.

    vhanytianmsft_0-1690272697856.png

     

     

    1. OnChange radio button:

    UpdateContext({varSelectedStockType:Radio1.Selected.Value});

    UpdateContext({varPartNumber:LookUp(Filter(Sort(Samples,'Part Number',SortOrder.Descending),Type = Radio1.Selected.Value),true,'Part Number')}); 

     

    vhanytianmsft_1-1690272697864.png

     

    2. Default text input:

    Concatenate(Left(varSelectedStockType,1),"-",Text(Value(Right(varPartNumber,Len(varPartNumber)-2))+1,"000000"))

     

    vhanytianmsft_2-1690272697869.png

     

     

    3. On Select Save button:

    SubmitForm(Form3);ResetForm(Form3);

    vhanytianmsft_3-1690272697872.png

     

     

    Hope this will help you,

     

    Best Regards,

    Tina

  • Az8PnG Profile Picture
    85 on at

    Hi @v-hanytian-msft is it possible to make the part number as a running number? Meaning that let say if the user choose "Electronic" then the part number will automatically + 1 such as "E-0000003", & display it in the text input. Then when the user click the save button, and choose "Electronic" again, the part number will be "E-000004".

  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @Az8PnG ,

     

    Please try to move the formula from OnChange to OnSelect.

    vhanytianmsft_2-1690334221399.png

    That means when you click Radio, it will execute the formula immediately.

     

    Hope this will help you,

    Best Regards,
    Tina

  • Az8PnG Profile Picture
    85 on at

    Hi Tina, I think the formula is not working on me.

     

    I already change it as you do, this is my OnSelect properties on radio button but the part number is not added to 1:

    Az8PnG_0-1690337722102.png

    Database table:

    Az8PnG_1-1690337779660.png

     

    Do you make the part number as primary key? Thank you for helping me out Tina. 😊

  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @Az8PnG ,

    May I ask what formula in the Default Text input?

     

    Best Regards,

    Tina

  • Az8PnG Profile Picture
    85 on at

    Sure Tina, here you go.

    Az8PnG_0-1690339067134.png

     

  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @Az8PnG ,

     

    Oddly enough, the same formula works fine in my app. But when I manually added a new record to the table, I reproduced the problem.

     

    We Suggest you add the refresh() formula into two places.

    Refresh(Samples)

    OnSelect of Radio:

    vhanytianmsft_0-1690339813991.png

    OnSelect of Button:

    vhanytianmsft_1-1690339892453.png

     

    Hope this will help you,

    Best Regards,
    Tina

     

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard