cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShaneITAutomate
Helper V
Helper V

Checkbox to turn off Auto Accriment and record last number (see pictures)

Hi,

 

Im stuck on a problem that is driving me nuts, below you will see an image of my test app,

ShaneITAutomate_0-1620302714109.png

 

This app currently uses the labels to make sure the user is using the correct text format which is in the range ZZ000001 - ZZ999999,

 

The text input is collected into the gallery and also uses the following onchange in the text input

If(Value(Right(SampleIDTEXTINPUT.Text,5))>000001&&Value(Right(SampleIDTEXTINPUT.Text,5))<999999&&IsMatch(Left(SampleIDTEXTINPUT.Text,2),"ZZ"),true,Notify("**Format of entered value should like ZZ000001**",NotificationType.Error);Reset(SampleIDTEXTINPUT))

 

when the app loads the intial text input needs to be blank and im currently im using the following in the default of the text input

 

If(IsBlank(Gallery1.AllItems),"", NextSampleID.Text)

 

I need the checkbox added to turn off the text formating so the user can enter empty sampleID's and i also need for the app to record the last (next) sample id number for when they turn the checkbox off it starts working as normal, so they can turn it off and on again as in the following example but instead of the 000001 it should be ZZ000005 the text input always reverts back to ZZ000001 using the above default code

 

ShaneITAutomate_1-1620303271714.png

 

 

 

 

11 REPLIES 11
timl
Super User
Super User

@ShaneITAutomate 

Can you post the formula that you're using to determine the value in your NextSampleID textbox? That's probably where the problem lies.


@timl wrote:

@ShaneITAutomate 

Can you post the formula that you're using to determine the value in your NextSampleID textbox? That's probably where the problem lies.


Thats the next sampleID text

 

Concatenate(First2Letters.Text,LastSubSampIDNumberPLus.Text)

 

The First2Letters is Just a textinput with ZZ in it and the other one is below

 

Text(LastSubSampIDNumber.Text + 1, "[$-en]000000")

 

And that one in this is below

 

Mid(LastSampleID.Text,3,100)

 

Which gets it from

 

Last(Gallery1.AllItems).SampleID

 

Hence the loop to make the numbers accrue upwards. I just want it too show the next sample id it should be and on the first time be blank so they have to put the first sample id in

 

Ie in the example above it should be showing ZZ000005 however if i press the checkbox it shows ZZ000001 again..

 

Anyone?

timl
Super User
Super User

@ShaneITAutomate 

I'm guessing this is reverting to 1 because the last item in your gallery has a empty sample ID value. I would try filtering out the blank values:

Last(Filter(Gallery1.AllItems, SampleID <> "").SampleID

 

timl
Super User
Super User

@ShaneITAutomate 

Thanks for your message, and apologies about the typo - there was missing closing bracket.

Last(Filter(Gallery1.AllItems, SampleID <> "")).SampleID


I think the key to this is to make sure that you can retrieve the ZZ000004 value, and hopefully the formula above will do this. Once this part works, everything should flow smoothly from that point onwards.

Its doesnt, i would have replied earlier but the microsoft and html data stopping me from posting and banning me for 3600secs everytime for no reason really drives me nuts

 

The Code just turns off the automatic accuring of text and values (Next sample Ids) and when turning the checkbox off and on it just keeps putting the same value over and over again (see pic below)

ShaneITAutomate_0-1620392077058.png

 

timl
Super User
Super User

@ShaneITAutomate 

Looking at you screenshot, it appears that you are determining the 'Next Sample ID' correctly - ZZ800802 in this example.

So presumably, I'm guessing that the fault lies in formula that's attached to 'Add button' button. Can you share the code that you have here? Are you calling Patch and referencing the correct sample ID?

Its just a simple collect code,

Collect(colTEST, {Title:"Title", SampleID:SampleIDTEXTINPUT.Text})

But the code needs to collect from the text input, the others are just labels that seperate the text into Text and numbers and then concatenates  (this code is the next sampleID in that label)

Concatenate(First2Letters.Text,LastSubSampIDNumberPLus.Text)

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,590)