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

I think your confused as to what im trying to do,

 

I want the users to press the check box and the data isnt collected (i can use a simple a IF statment in the collect code and use a visibility code to make the text input hide.)  Thats fine.

 

What i cannot figure out is somehow to save the Next Sample ID perhaps using a variable and if the user turns the check box off it changes whatever is in the text input box to the Next Sample ID (the text input under the checkbox and above the add button)

 

@timl

 

Also ive modified your code a little and now its swapping back and forth between two values.

 

I.e

ShaneITAutomate_0-1620531265852.png

 

 

Heres the add code

 

 

Collect(colTEST, {Title:"Title", 
SampleID: If(TurnOFFCHECKBOX.Value = true,"",SampleIDTEXTINPUT.Text), NextSampleID:NextSampleID.Text})

 

 

 

And heres the default code for the text input shown

 

 

 

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

 

 

 

It now goes back and forth between two values one of which is wrong, however it does keep the last sample ID

 

Also if i start the app fresh and press the check box straight away the text and numbers go to the first value in the auto accuring code ie ZZ000001

 

ie.

ShaneITAutomate_1-1620531595426.png

 

 

I want it to be blank at the start and force the user to put in a value so this onchange notify code works

 

 

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))

 

I also need it to recogonise its not at the start and im adding more than one empty sample ID that it remembers the last one and deosnt go back to ZZ000001

 

 

timl
Super User
Super User

@ShaneITAutomate 

 

I'm not sure that I fully understand what is happening here. I see this is is causing you some undue stress, so I hope that community here can help you resolve this quickly.

 

>> What i cannot figure out is somehow to save the Next Sample ID perhaps using a variable and if the user turns the check box off it changes whatever is in the text input box to the Next Sample ID (the text input under the checkbox and above the add button)

 

From what it sounds like here, this may just be a refresh issue. I can't understand the need to save the next Sample ID in a variable, if it's possible to determine the next sample ID from what's already there and in the gallery. I would experiment with resetting your text input control in the OnSelect of your checkbox:

Reset(SampleIDTEXTINPUT)

This will recalculate the value when the user checks the checkbox off, and back on again.

I would also consider setting the default value of the text input control to take into account the value of the checkbox.

If(TurnOFFCHECKBOX.Value = true,
   Last(Filter(Gallery1.AllItems, NextSampleID <> "")).NextSampleID,
   ""
)

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 (1,694)